Package com.google.appengine.datanucleus.test.jpa

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


  }
  public void testInsert_NewParentAndChild_StringPk_NoTxn() throws Exception {
    testInsert_NewParentAndChild_StringPk(NEW_EM_START_END);
  }
  private void testInsert_NewParentAndChild_StringPk(StartEnd startEnd) throws Exception {
    BidirectionalChildStringPkListJPA bidirChild = new BidirectionalChildStringPkListJPA();
    bidirChild.setChildVal("yam");

    Book b = newBook();

    HasKeyPkJPA hasKeyPk = new HasKeyPkJPA();
    hasKeyPk.setStr("yag");

    HasOneToManyStringPkListJPA parent = new HasOneToManyStringPkListJPA();
    parent.setId("yar");
    parent.getBidirChildren().add(bidirChild);
    bidirChild.setParent(parent);
    parent.getBooks().add(b);
    parent.getHasKeyPks().add(hasKeyPk);
    parent.setVal("yar");

    startEnd.start();
    em.persist(parent);
    startEnd.end();

    assertNotNull(bidirChild.getId());
    assertNotNull(b.getId());
    assertNotNull(hasKeyPk.getId());

    Entity bidirChildEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    assertNotNull(bidirChildEntity);
    assertEquals("yam", bidirChildEntity.getProperty("childVal"));
    assertEquals(KeyFactory.stringToKey(bidirChild.getId()), bidirChildEntity.getKey());
    assertKeyParentEquals(parent.getClass(), parent.getId(), bidirChildEntity, bidirChild.getId());

    Entity bookEntity = ds.get(KeyFactory.stringToKey(b.getId()));
    assertNotNull(bookEntity);
    assertEquals("max", bookEntity.getProperty("author"));
    assertEquals("22333", bookEntity.getProperty("isbn"));
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.BidirectionalChildStringPkListJPA

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.