When I create a country with 2 states in Java code, it fires 1 Country Insert, 2 State inserts and 2 update inserts.
Last 2 update inserts are for maintaining relationship link. It seems inefficient.
So to get over the stuff, I made following changes.
In country.hbm.xml, I said inverse="true" for <set> and for state.hbm.xml I said Many-to-one to country and also introduced a country variable in State.
So effectively I reversed the direction of relationship. Now if I save a country, state doesn't get saved in DB. When i have one to many in country.hbm.xml, why doesn't this work?
Best solution would be if approach 1 can work without having updates. Is there a way to do it?