assertEquals(1, entity.getProperties().size());
assertEquals("update", entity.getProperty("notUpdatable"));
}
public void testUpdate() throws EntityNotFoundException {
HasNonWritableFieldsJPA pojo = new HasNonWritableFieldsJPA();
pojo.setNotInsertable("insert");
pojo.setNotUpdatable("update");
pojo.setNotWritable("write");
beginTxn();
em.persist(pojo);
commitTxn();
em.clear();
if (em.getEntityManagerFactory().getCache() != null)
{
em.getEntityManagerFactory().getCache().evictAll();
}
beginTxn();
pojo = em.find(pojo.getClass(), pojo.getId());
pojo.setNotInsertable("insert2");
pojo.setNotUpdatable("update2");
pojo.setNotWritable("write2");
commitTxn();
Entity entity = ds.get(KeyFactory.createKey(kindForObject(pojo), pojo.getId()));
assertEquals(2, entity.getProperties().size());
assertEquals("insert2", entity.getProperty("notInsertable"));
assertEquals("update", entity.getProperty("notUpdatable"));
em.clear();
if (em.getEntityManagerFactory().getCache() != null)
{
em.getEntityManagerFactory().getCache().evictAll();
}
beginTxn();
pojo = em.find(pojo.getClass(), pojo.getId());
assertEquals("insert2", pojo.getNotInsertable());
assertEquals("update", pojo.getNotUpdatable());
assertNull(pojo.getNotWritable());
commitTxn();
}