aspose file tools*
The moose likes Object Relational Mapping and the fly likes Query after JPA collective update not getting updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Query after JPA collective update not getting updates" Watch "Query after JPA collective update not getting updates" New topic
Author

Query after JPA collective update not getting updates

Oliver Chua
Greenhorn

Joined: Feb 27, 2004
Posts: 29
Hi All,

I am using JPA on JSE.
I've added two records in the table, updated both records collectively,
and then retrieved both records to check they've been updated.

I've tried debugging, and the database is updated after the commit,
but the select doesn't return the newer versions.
If I get a new entity manager and use it to query, it passes.

Is there an explanation for this behavior
and is there a fix or a workaround without getting a new entity manager?

Thanks







Braden Walker
Greenhorn

Joined: Apr 10, 2014
Posts: 1
I would suggest trying an EntityManager.flush() after executing your update, and before doing an EntityManager.getTransaction().commit() - I had a very similar problem, and this worked for me.
 
Don't get me started about those stupid light bulbs.
 
subject: Query after JPA collective update not getting updates