Hi,
I have two entities A and B (names changed). A has Set of B objects. A is mapped to B with <set cascade="all-delete-orphan" inverse="true" ...>.
I want to delete the old Bs and reinsert the new ones.
When I do A.getBs().clear() and A.getBs().addAll(setOfNewBs) , it first INSERTs the new B in DB and then fires DELETE queries. I know this can be resolved by firing flush() on Session after A.getBs().clear(). Is there any other way, I can specify some option so, that Hibernate first deletes the child elements and then inserts new ones. I have a constraint on the child table which checks Sequence Number of B and A's ID.
Thanks in advance for looking.
|