You can refresh a single entity like this
Or, you can close the entity manager
The next call to getEntityManager() should return a fresh instance.
See the org.jboss.seam.framework.EntityController class, also, refer to
Hibernate Entity Manager
If it is a simple query the get a list of entities, the easiest thing would be to call
entityManager.clear() before you issue the query. Depending on how many entities the
query returns, that might be quite slow, so use with caution :) It could also break stuff
in other tabs, if you are using lazy relationships.
Thanks you both!!
Hmmm, interestingly, the Hibernate Entity Manager documentation states that a flush will be automatically performed, and the state synchronized with the database, before query execution. It does specify that a transaction must be active, perhaps that is something you could check.
See this post:
I think that, in this case,
synchronization with the data storemeans writing out changes, not refreshing entities.