Hi,
I have a process of Orders where I load Order and all their OrdemItem, and I’m having problems with this situation:
Order: PK[id = 1];
OrderItem: PK[order_id = 1, order_line = 1];
OrderItem: PK[order_id = 1, order_line = 2];
So I remove the Object (OrderItem: PK[order_id = 1, order_line = 1]), only in collection because I don’t want to delete in database before the user confirm the whole process. But for any reason the user add the same OrderItem again in the collection.
If I merge the father (Order) after that I’m getting:
A different object with the same identifier value was already associated with the session
If I remove the OrderItem in database when I remove it from the collection it works, but I want to keep it in the database because the user could abort the process.
Is there any elegant approach to do this with Hibernate? Or should I do a workaround with @Transient attribute or another collection?
Thanks in advance