use of org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.NoIdentityMap in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testRefreshEntityWithoutCache.
public void testRefreshEntityWithoutCache() {
EntityManager em = createEntityManager();
NoIdentityMap map = new NoIdentityMap();
map.setName("bob");
beginTransaction(em);
em.persist(map);
commitTransaction(em);
if (!isOnServer()) {
closeEntityManager(em);
em = createEntityManager();
}
clearCache();
beginTransaction(em);
Query query = em.createQuery("Select e from NoIdentityMap e where e.name = 'bob'");
NoIdentityMap emp = (NoIdentityMap) query.getSingleResult();
int version = emp.getVersion();
query.setHint(QueryHints.REFRESH, true);
emp = (NoIdentityMap) query.getSingleResult();
commitTransaction(em);
if (!isOnServer()) {
closeEntityManager(em);
em = createEntityManager();
}
beginTransaction(em);
em.remove(em.find(NoIdentityMap.class, map.getID()));
commitTransaction(em);
if (!isOnServer()) {
closeEntityManager(em);
}
assertEquals("Unchanged employee had version changed after refresh", version, emp.getVersion());
}
Aggregations