-
1. Re: Refreshing database
joblini Dec 18, 2008 7:24 AM (in response to charlscross)Hi Charls,
You can refresh a single entity like this
getEntityManager().refresh(getInstance());
Or, you can close the entity manager
getEntityManager().close()
The next call to getEntityManager() should return a fresh instance.
See the org.jboss.seam.framework.EntityController class, also, refer to
Hibernate Entity Manager -
2. Re: Refreshing database
kapitanpetko Dec 18, 2008 7:54 AM (in response to charlscross)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. -
3. Re: Refreshing database
charlscross Dec 18, 2008 9:36 AM (in response to charlscross)Thanks you both!!
-
4. Re: Refreshing database
joblini Dec 18, 2008 6:47 PM (in response to charlscross)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:
-
5. Re: Refreshing database
joblini Dec 18, 2008 7:27 PM (in response to charlscross)I think that, in this case,
synchronization with the data store
means writing out changes, not refreshing entities.