Examples of HasNonWritableFieldsJPA


Examples of com.google.appengine.datanucleus.test.jpa.HasNonWritableFieldsJPA

* @author Max Ross <max.ross@gmail.com>
*/
public class JPANonWritableFieldsTest extends JPATestCase {

  public void testInsert() 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());
    assertNull(pojo.getNotInsertable());
    assertEquals("update", pojo.getNotUpdatable());
    assertNull(pojo.getNotWritable());
    commitTxn();
    Entity entity = ds.get(KeyFactory.createKey(kindForObject(pojo), pojo.getId()));
    assertEquals(1, entity.getProperties().size());
    assertEquals("update", entity.getProperty("notUpdatable"));
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.HasNonWritableFieldsJPA

    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();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.