Hi,
The scenario:
I'm working with some pojo Article.
1) createSession() 2) session.merge(Article ) 3) session.saveOrUpdate(Article) 3) closeSession() // Article dbVersion=2 .... 4) createSession() 5) session.merge(Article ) Here I'm getting StaleObjectStateException with strange state values. When I inspect in debugger variables of DefaultMergeEventListener.entityIsDetached() I see that entity.dbVersion=2, while target.dbVersion=1. So, the target variable contains very old version of the Article. How can I prevent loading of old version? (where does it come from?)
The application is multi-threaded in its nature, however the process of handling of Article instance is serial, so I don't see place for multi-threaded collisions. Of course, each thread is using different instance of Session.
|