Hey,
Lets say i have a Buyer obj , each Buyer has reference to BooksCollection obj .
The primary key of BooksCollection is the hash value of the names of the books that it contains.
In the BuyerDAO i check (by session.get ) if the BooksCollection already in the seesion.
In case it is i get it from the session and set it to the Buyer
Than call to session.saveOrUpdate(Buyer)
Scenario:
Multi thread application.
Two Buyer with the same BooksCollection from differents threads come in the same time.
Code:
Exception - java.sql.SQLException: Duplicate entry '1075191317' for key 1
I close the session and try to save (The same logic like above) the Buyer again , but faild with :
Code:
org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
Please, Please ,Please,
I am trying to sove it for a long time.
Thank you