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

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


public class Issue62Test extends JDOTestCase {

  public void testMultipleOneToOne() {
    Issue62Parent parent;
    Issue62Child child;
    {
      child = new Issue62Child();
      parent = new Issue62Parent(child);
      pm.makePersistent(parent);
      pm.close();
    }

    // Create a second parent/child and next update the first child with the second parent
    Issue62Parent parent2;
    {
      pm = pmf.getPersistenceManager();
      parent2 = new Issue62Parent(new Issue62Child());
      pm.makePersistent(parent2);
      pm.close();

      try {
        pm = pmf.getPersistenceManager();
        pm.currentTransaction().begin();
        Issue62Child childToChangeParent = pm.getObjectById(Issue62Child.class, child.getId());
        assertNotNull(childToChangeParent);
        childToChangeParent.setParent(parent2);
        parent2.setChild(childToChangeParent);
        pm.currentTransaction().commit();
        fail("Didn't throw exception on attempt to change parent");
      } catch (JDOException jdoe) {
        // Expected
      }
      finally {
        if (pm.currentTransaction().isActive()) {
          pm.currentTransaction().rollback();
        }
        pm.close();
      }
    }

    // check the update
    {
      pm = pmf.getPersistenceManager();
      Issue62Child changedParent = pm.getObjectById(Issue62Child.class, child.getId());
      assertEquals(parent.getId(), changedParent.getParent().getId()); // <-- the update doen't take effect? why?
      pm.close();
    }
  }
View Full Code Here

TOP

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

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.