Examples of HasOneToManyListJPA


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

    commitTxn();
    assertEquals(1, countForClass(Book.class));
  }

  public void testDeleteDoesNotCascade() {
    HasOneToManyListJPA parent = new HasOneToManyListJPA();
    Book b = new Book();
    b.setAuthor("author");
    parent.getBooks().add(b);
    beginTxn();
    em.persist(parent);
    commitTxn();
    assertEquals(1, countForClass(Book.class));
    assertEquals(1, countForClass(HasOneToManyListJPA.class));
View Full Code Here

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

    assertEquals(Utils.newArrayList("c", "d", "e"), e.getProperty("strList"));
  }

  public void testSerializeWithOneToMany_AddChildToBidirectionalDetached() throws Exception {
    beginTxn();
    HasOneToManyListJPA pojo = new HasOneToManyListJPA();
    pojo.setVal("yar");
    BidirectionalChildListJPA bidir = new BidirectionalChildListJPA();
    bidir.setChildVal("yar2");
    pojo.getBidirChildren().add(bidir);
    em.persist(pojo);
    commitTxn();
    em.close();
    em = emf.createEntityManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getBidirChildren().size());
    BidirectionalChildListJPA bidir2 = new BidirectionalChildListJPA();
    bidir.setChildVal("yar3");
    pojo.getBidirChildren().add(bidir2);
    // Don't set the parent - this ref won't get updated when we call
    // merge and we'll get an exception.
//    bidir2.setParent(pojo);
    beginTxn();
    pojo = em.merge(pojo);
    commitTxn();
    Entity e = ds.get(KeyFactory.stringToKey(bidir2.getId()));
    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }
View Full Code Here

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

    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }

  public void testSerializeWithOneToMany_AddChildToUnidirectionalDetached() throws Exception {
    beginTxn();
    HasOneToManyListJPA pojo = new HasOneToManyListJPA();
    pojo.setVal("yar");
    Book b = new Book();
    b.setAuthor("harry");
    pojo.getBooks().add(b);
    em.persist(pojo);
    commitTxn();
    em.close();
    em = emf.createEntityManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getBooks().size());
    Book b2 = new Book();
    b2.setAuthor("yar3");
    pojo.getBooks().add(b2);
    // Don't set the parent - this ref won't get updated when we call
    // merge and we'll get an exception.
//    bidir2.setParent(pojo);
    beginTxn();
    pojo = em.merge(pojo);
    commitTxn();
    Entity e = ds.get(KeyFactory.stringToKey(b2.getId()));
    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }
View Full Code Here

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

    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }

  public void testSerializeWithOneToMany_AddChildToReattached() throws Exception {
    beginTxn();
    HasOneToManyListJPA pojo = new HasOneToManyListJPA();
    pojo.setVal("yar");
    BidirectionalChildListJPA bidir = new BidirectionalChildListJPA();
    bidir.setChildVal("yar2");
    pojo.getBidirChildren().add(bidir);
    em.persist(pojo);
    commitTxn();
    em.close();
    em = emf.createEntityManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getBidirChildren().size());
    beginTxn();
    pojo = em.merge(pojo);
    BidirectionalChildListJPA bidir2 = new BidirectionalChildListJPA();
    bidir.setChildVal("yar3");
    pojo.getBidirChildren().add(bidir2);
    bidir2.setParent(pojo);
    commitTxn();
    Entity e = ds.get(KeyFactory.stringToKey(bidir2.getId()));
    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }
View Full Code Here

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

* @author Max Ross <maxr@google.com>
*/
public class JPAOneToManyListTest extends JPAOneToManyTestCase {

  public void testInsert_NewParentAndChild() throws Exception {
    testInsert_NewParentAndChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                 TXN_START_END);
  }
View Full Code Here

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

    testInsert_NewParentAndChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                 TXN_START_END);
  }

  public void testInsert_NewParentAndChild_NoTxn() throws Exception {
    testInsert_NewParentAndChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                 NEW_EM_START_END);
  }
View Full Code Here

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

    testInsert_NewParentAndChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                 NEW_EM_START_END);
  }

  public void testInsert_ExistingParentNewChild() throws Exception {
    testInsert_ExistingParentNewChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      TXN_START_END);
  }
View Full Code Here

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

    testInsert_ExistingParentNewChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      TXN_START_END);
  }

  public void testInsert_ExistingParentNewChild_NoTxn() throws Exception {
    testInsert_ExistingParentNewChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      NEW_EM_START_END);
  }
View Full Code Here

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

    testInsert_ExistingParentNewChild(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      NEW_EM_START_END);
  }

  public void testUpdate_UpdateChildWithMerge() throws Exception {
    testUpdate_UpdateChildWithMerge(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      TXN_START_END);
  }
View Full Code Here

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

    testUpdate_UpdateChildWithMerge(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      TXN_START_END);
  }

  public void testUpdate_UpdateChildWithMerge_NoTxn() throws Exception {
    testUpdate_UpdateChildWithMerge(new BidirectionalChildListJPA(), new HasOneToManyListJPA(),
                                      NEW_EM_START_END);
  }
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.