Package com.google.appengine.datanucleus.test.jdo

Examples of com.google.appengine.datanucleus.test.jdo.Issue271Child


    Object c1Id = null;
    Object c2Id = null;
    try {
      pm.currentTransaction().begin();
      Issue271Parent p = new Issue271Parent();
      Issue271Child c1 = new Issue271Child();
      Issue271Child c2 = new Issue271Child();
      p.getChildren().add(c1);
      p.getChildren().add(c2);
      c1.setParent(p);
      c2.setParent(p);
      pm.makePersistent(p);
      pm.currentTransaction().commit();

      pId = pm.getObjectId(p);
      c1Id = pm.getObjectId(c1);
      c2Id = pm.getObjectId(c2);
    } catch (Exception e) {
      NucleusLogger.GENERAL.error(">> Exception in persist", e);
      fail("Failure during persist : " + e.getMessage());
    } finally {
      if (pm.currentTransaction().isActive()) {
        pm.currentTransaction().rollback();
      }
      pm.close();
    }
    pmf.getDataStoreCache().evictAll();

    pm = pmf.getPersistenceManager();
    Issue271Child c1 = (Issue271Child) pm.getObjectById(c1Id);
    pm.deletePersistent(c1);
    pm.close();

    pm = pmf.getPersistenceManager();
    Issue271Parent p = (Issue271Parent)pm.getObjectById(pId);
    List<Issue271Child> children = p.getChildren();
    assertNotNull(children);
    NucleusLogger.GENERAL.info(">> Accessing children");
    Issue271Child c = children.get(0);
    assertEquals(1, children.size());
    assertEquals(c2Id, JDOHelper.getObjectId(c));
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.Issue271Child

Copyright © 2018 www.massapicom. 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.