Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query after JPA collective update not getting updates

 
Oliver Chua
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic