Hibernate (JPA): how to handle StaleObjectStateException when several object has been modified and commited
Consider the scenario: A Db transaction envolving more than one row from different tables with versioning. For example: A shopLists and products. Where a shopList may contain products (with their amount in the shoplist) and products have their current stock. When I insert ou edit a shopList, I want the stock of those products in the shopList to be updated to keep the stock consistant. To do that, I open a transaction, insert/update the shopList, update the stocks for each product (apply delta) and then commit the transaction. No big deal up to now. However, other user may have updated one or