I am using a combination of Spring 2.5.6 and Hibernate Annotations. I have three objects(tables or w/e) under consideration: Customer, Address, Order. Customer has the Cascade DELETE_ORPHANS property set for addresses.
What i am doing is a customer merge, i'm moving all addresses and orders from one customer to another, then setting a disabled bit on the old customer. I do this by removing addresses from CustB and adding them to CustA. Then i save CustA with .update(custA), the addresses and orders move appropriately, but when I update custB with the disabled bit it erases my moved addresses!
When i comment out the DELETE_ORPHANS it works fine.
How do I stop DELETE_ORPHANS from removing the moved addresses? Should I not remove them from the custB and just change their customer reference? If i do it all within a transaction insead of detaching the objects inbetween each operation will they update properly with DELETE_ORPHAN enabled?