Originally posted by Nitin Kasat:
Ok. So Hibernate will takecare of avoiding duplication. That is it will generate the id only if it is not able to find the same object in the database and if it finds then will assign the existing id. Am I right what you mean to say? Thanks for your reply.
Not exactly. When you call saveOrUpdate, hibernate will look at the B object and call getId. If it does not return a value, hibernate will assume it needs to do an insert. So make sure the B object has an id already. How to do that, load your B objects from the database is one way. Use a second level cache to cache the B objects is another way.
Mark