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

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


    assertEquals(bId, pm.getObjectId(b2));
  }

  public void testListPersistUniNewBoth() throws EntityNotFoundException {
    // Persist A-B as unowned
    UnownedJDOOneToManyUniListSideA a = new UnownedJDOOneToManyUniListSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b = new UnownedJDOOneToManyUniSideB();
    b.setName("Side B");
    a.addOther(b);

    pm.makePersistent(a);

    Object aId = pm.getObjectId(a);
    Object bId = pm.getObjectId(b);

    pm.evictAll(); // Make sure we go to the datastore

    // Retrieve by id and check
    UnownedJDOOneToManyUniListSideA a2 = (UnownedJDOOneToManyUniListSideA)pm.getObjectById(aId);
    assertNotNull(a2);
    assertEquals("Side A", a2.getName());
    List<UnownedJDOOneToManyUniSideB> others = a2.getOthers();
    assertNotNull(others);
    assertEquals(1, others.size());
    UnownedJDOOneToManyUniSideB b2 = others.iterator().next();
    assertNotNull(b2);
    assertNotNull("Side B", b2.getName());
View Full Code Here


    bs = (List<UnownedJDOOneToManyUniSideB>) pm.newQuery("select from " + UnownedJDOOneToManyUniSideB.class.getName()).execute();
    assertEquals(2, bs.size());
  }

  public void testListDeleteOwnerNotDependent() {
    UnownedJDOOneToManyUniListSideA a = new UnownedJDOOneToManyUniListSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b1 = new UnownedJDOOneToManyUniSideB();
    b1.setName("First B");
    UnownedJDOOneToManyUniSideB b2 = new UnownedJDOOneToManyUniSideB();
    b2.setName("Second B");
    a.addOther(b1);
    a.addOther(b2);
    pm.makePersistent(a);
    pm.close();

    pm = pmf.getPersistenceManager();
    List<UnownedJDOOneToManyUniListSideA> as = (List<UnownedJDOOneToManyUniListSideA>)
View Full Code Here

    bs = (List<UnownedJDOOneToManyUniSideB>) pm.newQuery("select from " + UnownedJDOOneToManyUniSideB.class.getName()).execute();
    assertEquals(2, bs.size());
  }

  public void testUnownedDelete() {
    UnownedJDOOneToManyUniListSideA p = new UnownedJDOOneToManyUniListSideA();
    UnownedJDOOneToManyUniSideB c1 = new UnownedJDOOneToManyUniSideB();
    p.addOther(c1);
    UnownedJDOOneToManyUniSideB c2 = new UnownedJDOOneToManyUniSideB();
    p.addOther(c2);

    pm.makePersistent(p);
    pm.close();

    pm = pmf.getPersistenceManager();
View Full Code Here

    List<UnownedJDOOneToManyUniSideB> children = (List<UnownedJDOOneToManyUniSideB>)
      pm.newQuery( "select from " + UnownedJDOOneToManyUniSideB.class.getName() ).execute();
    assertEquals(2, children.size());

    // create parent without children, store, detach
    UnownedJDOOneToManyUniListSideA p = new UnownedJDOOneToManyUniListSideA();
    p = pm.makePersistent(p);
    pm.getFetchPlan().setGroup(FetchPlan.ALL);
    UnownedJDOOneToManyUniListSideA pDetached = pm.detachCopy(p);
    assertTrue(JDOHelper.isDetached(pDetached));

    // add already persistent children
    pDetached.getOthers().add(pm.detachCopy(c1));
    pDetached.getOthers().add(pm.detachCopy(c2));

    // update parent
    pm.makePersistent(pDetached);
    pm.close();
View Full Code Here

TOP

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

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.