Caching or Isolations-Level Problem? [message #385301] |
Mon, 26 January 2009 18:19  |
Eclipse User |
|
|
|
Hello,
i'm playing around with the sample application
org.eclipse.persistence.example.jpa.employee.xml and having one hard
problem. For testing purpose i write my own test who read a List of
objects modifiing them and makes them persistent. After the commit i
change the data with another client (MySQL Querry-Browser). I'm not able
to read those external commited changes. I know this problem from jdbc. We
have to set the isolation level TRANSACTION_READ_COMMITTED to be able to
read those changes back. MySQL start by default with a harder isolation
level and supressing reading of commited Data.
I've tryed to disabled the cache in orm.xml and via annotation.
Whats wrong? Isolation level, caching, or unsing an EntityManager?
Here ist the Sample Code.
EntityManager em = getEMF().createEntityManager();
List<LargeProject> projectListPrimary;
List<LargeProject> projectListSecondary;
em.getTransaction().begin();
projectListPrimary = (List<LargeProject> ) em.createQuery("SELECT e FROM
LargeProject e").getResultList();
for ( LargeProject number : projectListPrimary ) {
number.setDescription(number.getDescription() + "-666");
em.persist(number);
}
em.getTransaction().commit();
|
|
|
Re: Caching or Isolations-Level Problem? [message #385307 is a reply to message #385301] |
Tue, 27 January 2009 08:04   |
Eclipse User |
|
|
|
An EntityManager represents an extended persistence context, so anything
read into an EntityManager will not be refreshed unless you explicitly
call refresh() on the object, or clear() the EntityManager. You can also
create a new EntityManager, and the life-cycle on an EntityManager
typically corresponds to one transaction or request.
EclipseLink also provides a query hint to refresh,
"eclipselink.refresh"="true".
EclipseLink also has a shared cache for the persistence unit, so anything
read can also be in the cache, and not refreshed until either explicitly
refreshed, or invalidated. To disable the EclipseLink cache set the
persistence.xml property "eclipselink.cache.shared.default"="false".
See also,
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Extensions_for_Entity_Caching
and,
http://wiki.eclipse.org/Optimizing_the_EclipseLink_Applicati on_(ELUG)#Optimizing_Cache
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03141 seconds