开发者

jpa find problem

the find method does not return the latest version of an object. somewhere in my code I find an object, change it, merge it and commit my changes. In the database the changes are made but in another function I find this object and my changes are not there. I've checked race-conditions with the result that there are no race-conditions. I've checked if there are duplicates of this object or different ids but that works fine.

Does anyone have an i开发者_JAVA百科dea?

db: mysql persistence: eclipselink


Do you have an EntityManager already open while another EntityManager does the merge/commit? The stale entity might be coming from an EntityManager that is not yet sync'ed with the changes committed to the database in another EntityManager elsewhere.

Try calling the flush() method on the EntityManager that needs to be sync'ed.


jim is right. I've got two EntittyManager which are out of sync. My solution is now to have only one entity-manager. Is there a nice solution to get both manager synced because I have two threads and it can be possible that both threads wants to begin a transaction at the same time for instance which might be a problem...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜