Invalidation and JPA [message #516591] |
Wed, 24 February 2010 13:52 |
No real name Messages: 2 Registered: February 2010 |
Junior Member |
|
|
Hello,
i have a problem with manually invalidating a entity in the cache using the identitymap api. The object is invalid but it is not refreshed when it is accessed again.
The following code snipped executes only a single SQL but it should execute another one to refresh the invalid entity:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("default");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
MyEntity entity = em.find(MyEntity .class, "20");
Session eclipselinkSession = ((JpaEntityManager)em.getDelegate()).getActiveSession();
eclipselinkSession.getIdentityMapAccessor().invalidateObject(entity);
eclipselinkSession = ((JpaEntityManager)em.getDelegate()).getServerSession();
eclipselinkSession.getIdentityMapAccessor().invalidateObject(entity);
boolean valid = eclipselinkSession.getIdentityMapAccessor().isValid(entity);
em.getTransaction().commit();
em.getTransaction().begin();
entity = em.find(MyEntity.class, "20");
valid = eclipselinkSession.getIdentityMapAccessor().isValid(entity);
em.getTransaction().commit();
em.close();
emf.close();
Is it even possible to use the invalidation api together with JPA? Did i miss something else?
Tested it with EclipseLink 1.02, 1.1.1, 2.0
Regards Axel
Edit: is this possibly related to this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=272895
Edit2:
With the native API from eclipselink the entity is refreshed as expected
eclipselinkSession.readObject(new MyEntity("20"));
[Updated on: Thu, 25 February 2010 12:24] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04101 seconds