* This test ensures that after executing an update against the db, the updated type is purged from
* the DataCache.
*/
public void testUpdate() throws Exception {
EntityManager em = emf.createEntityManager();
Cache cache = emf.getCache();
try {
CachedEntityStatistics e = createEntity(em);
assertTrue(cache.contains(CachedEntityStatistics.class, e.getId()));
em.clear();
String update = "UPDATE CachedEntityStatistics s SET s.firstName = :name WHERE s.id = :id";
String name = "name_" + System.currentTimeMillis();
// execute update, this should result in a cache eviction
em.getTransaction().begin();
assertEquals(1, em.createQuery(update).setParameter("name", name).setParameter("id", e.getId())
.executeUpdate());
em.getTransaction().commit();
assertFalse(cache.contains(CachedEntityStatistics.class, e.getId()));
CachedEntityStatistics postUpdate = em.find(CachedEntityStatistics.class, e.getId());
assertEquals(name, postUpdate.getFirstName());
} finally {