Hello everyone !
I have a problem with my small game application using Hibernate when I try to save an entity which have a modified collection of others entities in it.
The program throws this exception : "
Reassociated object has dirty collection" at this line :
https://github.com/debnet/ircrpg/blob/master/src/fr/debnet/ircrpg/DAO.java#L163
Nevertheless, the data seems to be
successfully updated in the database !
I well understand the meaning of this message but since weeks I can't find something to help me.
I reached the 10th result page in Google, I directly ask my question on Freenode, search all over Hibernate forums... there is something here I don't understand.
Here my use case :
https://github.com/debnet/ircrpg/blob/master/src/fr/debnet/ircrpg/game/Game.java#L1338-1361
- A player wants to buy an item
- After several checks, the stock of entity instance "Item" is decreased
- The item is saved in order to persist the new stock value
- The item is added in the "items" collection of the entity instance "Player"
- The player is saved in order to persist the new object in his inventory
- Exception on save (or on lock) but data correctly updated
For my purpose, I created an custom DAO in order to hide the Hibernate process in my application.
I'm pretty sure there is something wrong about my comprehension of the internal mechanisms.
Please help me. ;)
PS: Sorry for my english, I clearly had a lack of practice...