The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: Query.getResultList() don't show database updates

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 1 - Last Post: Dec 23, 2008 4:11 PM by: cowwoc
tonhinbm

Posts: 4
Query.getResultList() don't show database updates
Posted: Dec 23, 2008 4:44 AM
  Click to reply to this thread Reply

The problem is that:
The first time I execute query.getResultList() it reads data from database, but if database change after, I can't see that changes until I close or clear entity manager.

Is there any way to force query.getResultList() reads data ALWAYS from database without clearing or closing entity manager.

Thanks.

cowwoc

Posts: 1,055
Re: Query.getResultList() don't show database updates
Posted: Dec 23, 2008 4:11 PM   in response to: tonhinbm
  Click to reply to this thread Reply

Short answer: you need to use EntityManager.refresh() on the query results

Long answer: http://www.nabble.com/Query-returning-stale-results-existing-td20559804.html




 XML java.net RSS