pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
em.persist(pc);
em.getTransaction().commit();
Object oid = pc.getId();
StoreCache dataCache = emf.getStoreCache();
assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
// delete the record in the database in a separate transaction using
// native SQL so that the in-memory instance is not altered
em.getTransaction().begin();
String sql = "DELETE FROM L2_PObject WHERE id="+oid;
em.createNativeQuery(sql).executeUpdate();
em.getTransaction().commit();
// the object cache does not know that the record was deleted
assertTrue(em.contains(pc));
// nor does the data cache
assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
/**
* refresh behavior no more depends on current lock. Refresh
* will always attempt to fetch the instance from database
* raising EntityNotFoundException.