I have insert having flanking regions with XbaI site and and a vector digested with XbaI. How can I prevent self ligation in insert as well as vector before ligation?
Usually what you do in such case, is that you dephosphorylate your vector with a phosphatase to prevent self-ligation and then perform the ligation.
If the insert self-ligates, it will decrease yield of your ligation, but it won't give you colonies, because it doesn't have ori, selection etc.
The vector should not be able to self-ligate so you shouldn't get colonies with empty vector.
And the vector and insert should ligate at one strand, which is sufficient and bacteria will repair the single strand nick.
However, if possible, you should avoid ligating through the same RE, as it is difficult to ligate and it may insert in both directions (to check quickly, you can design one primer for vector and one for insert and perform colony PCR to quickly distinguish).
If your ligation wouldn't work, I would recommend designing primers for fusion PCR to get your insert into the plasmid quickly.