Examples of HasOneToManyListJDO


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

    owner2Entity.setProperty("flights", Utils.newArrayList(fl3.getKey(), fl4.getKey()));
    owner2Entity.setProperty("bidirChildren", Utils.newArrayList(bi3.getKey(), bi4.getKey()));
    ds.put(owner2Entity);

    HasOneToManyListJDO parent1 = pm.getObjectById(HasOneToManyListJDO.class, k1);
    assertEquals(2, parent1.getFlights().size());
    assertEquals(2, parent1.getBidirChildren().size());
    HasOneToManyListJDO parent2 = pm.getObjectById(HasOneToManyListJDO.class, k2);
    assertEquals(2, parent2.getFlights().size());
    assertEquals(2, parent2.getBidirChildren().size());
    pm.deletePersistentAll(parent1, parent2);
    assertEquals(0, countForClass(HasOneToManyListJDO.class));
    assertEquals(0, countForClass(Flight.class));
    assertEquals(0, countForClass(BidirectionalChildListJDO.class));
    assertEquals(1, batchRecorder.batchOps);
View Full Code Here

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

    owner2Entity.setProperty("flights", Utils.newArrayList(fl3.getKey(), fl4.getKey()));
    owner2Entity.setProperty("bidirChildren", Utils.newArrayList(bi3.getKey(), bi4.getKey()));
    ds.put(owner2Entity);

    beginTxn();
    HasOneToManyListJDO parent1 = pm.getObjectById(HasOneToManyListJDO.class, k1);
    assertEquals(2, parent1.getFlights().size());
    assertEquals(2, parent1.getBidirChildren().size());
    commitTxn();
    beginTxn();
    HasOneToManyListJDO parent2 = pm.getObjectById(HasOneToManyListJDO.class, k2);
    assertEquals(2, parent2.getFlights().size());
    assertEquals(2, parent2.getBidirChildren().size());
    commitTxn();
    beginTxn();
    try {
      pm.deletePersistentAll(parent1, parent2);
      fail("expected exception");
View Full Code Here

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

    owner2Entity.setProperty("flights", Utils.newArrayList(fl3.getKey(), fl4.getKey()));
    owner2Entity.setProperty("bidirChildren", Utils.newArrayList(bi3.getKey(), bi4.getKey()));
    ds.put(owner2Entity);

    beginTxn();
    HasOneToManyListJDO parent1 = pm.getObjectById(HasOneToManyListJDO.class, k1);
    assertEquals(2, parent1.getFlights().size());
    assertEquals(2, parent1.getBidirChildren().size());
    HasOneToManyListJDO parent2 = pm.getObjectById(HasOneToManyListJDO.class, k2);
    assertEquals(2, parent2.getFlights().size());
    assertEquals(2, parent2.getBidirChildren().size());
    pm.deletePersistentAll(parent1, parent2);
    commitTxn();

    assertEquals(0, countForClass(HasOneToManyListJDO.class));
    assertEquals(0, countForClass(Flight.class));
View Full Code Here

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

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

  public void testDeleteCascades() {
    HasOneToManyListJDO parent = new HasOneToManyListJDO();
    Flight f = new Flight();
    parent.getFlights().add(f);
    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    assertEquals(1, countForClass(Flight.class));
    assertEquals(1, countForClass(HasOneToManyListJDO.class));
View Full Code Here

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

    Entity bidirEntity = new Entity(BidirectionalChildListJDO.class.getSimpleName(), parentEntity.getKey());
    ds.put(null, bidirEntity);
    Entity bidirEntity2 = new Entity(BidirectionalChildListJDO.class.getSimpleName(), parentEntity.getKey());
    ds.put(null, bidirEntity2);

    HasOneToManyListJDO parent =
        pm.getObjectById(HasOneToManyListJDO.class, KeyFactory.keyToString(parentEntity.getKey()));
    Query q = pm.newQuery(
        "select from " + BidirectionalChildListJDO.class.getName()
        + " where parent == p parameters " + HasOneToManyListJDO.class.getName() + " p");
    List<BidirectionalChildListJDO> result = (List<BidirectionalChildListJDO>) q.execute(parent);
View Full Code Here

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

  }

  public void testSerializeWithOneToMany_AddBidirectionalChildToDetached() throws Exception {
    pm.setDetachAllOnCommit(true);
    beginTxn();
    HasOneToManyListJDO pojo = new HasOneToManyListJDO();
    pojo.setVal("yar");
    BidirectionalChildListJDO bidir = new BidirectionalChildListJDO();
    bidir.setChildVal("yar2");
    pojo.addBidirChild(bidir);
    pm.makePersistent(pojo);
    commitTxn();
    pm.close();
    pm = pmf.getPersistenceManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getBidirChildren().size());
    BidirectionalChildListJDO bidir2 = new BidirectionalChildListJDO();
    bidir2.setChildVal("yar3");
    pojo.addBidirChild(bidir2);
    bidir2.setParent(pojo);
    beginTxn();
    pojo = pm.makePersistent(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.jdo.HasOneToManyListJDO

  }

  public void testSerializeWithOneToMany_AddUnidirectionalChildToDetached() throws Exception {
    pm.setDetachAllOnCommit(true);
    beginTxn();
    HasOneToManyListJDO pojo = new HasOneToManyListJDO();
    pojo.setVal("yar");
    Flight flight = new Flight();
    flight.setName("harry");
    pojo.addFlight(flight);
    pm.makePersistent(pojo);
    commitTxn();
    pm.close();
    pm = pmf.getPersistenceManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getFlights().size());
    Flight flight2 = new Flight();
    flight2.setName("not harry");
    pojo.addFlight(flight2);
    beginTxn();
    pojo = pm.makePersistent(pojo);
    commitTxn();
    Entity e = ds.get(KeyFactory.stringToKey(flight2.getId()));
    assertEquals(KeyFactory.stringToKey(pojo.getId()), e.getKey().getParent());
  }
View Full Code Here

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

  }

  public void testSerializeWithOneToMany_AddChildToReattached() throws Exception {
    pm.setDetachAllOnCommit(true);
    beginTxn();
    HasOneToManyListJDO pojo = new HasOneToManyListJDO();
    pojo.setVal("yar");
    BidirectionalChildListJDO bidir = new BidirectionalChildListJDO();
    bidir.setChildVal("yar2");
    pojo.addBidirChild(bidir);
    pm.makePersistent(pojo);
    commitTxn();
    pm.close();
    pm = pmf.getPersistenceManager();

    pojo = toBytesAndBack(pojo);
    assertEquals("yar", pojo.getVal());
    assertEquals(1, pojo.getBidirChildren().size());
    beginTxn();
    pojo = pm.makePersistent(pojo);
    BidirectionalChildListJDO bidir2 = new BidirectionalChildListJDO();
    bidir.setChildVal("yar3");
    pojo.addBidirChild(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.jdo.HasOneToManyListJDO

    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testInsertNewParentAndChild(NEW_PM_START_END);
  }
  private void testInsertNewParentAndChild(StartEnd startEnd) throws EntityNotFoundException {
    HasOneToManyListJDO parent = new HasOneToManyListJDO();
    BidirectionalChildListJDO bidirChild = new BidirectionalChildListJDO();
    testInsert_NewParentAndChild(parent, bidirChild, startEnd);
  }
View Full Code Here

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

    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testInsertExistingParentNewChild(NEW_PM_START_END);
  }
  private void testInsertExistingParentNewChild(StartEnd startEnd) throws EntityNotFoundException {
    HasOneToManyListJDO parent = new HasOneToManyListJDO();
    BidirectionalChildListJDO bidirChild = new BidirectionalChildListJDO();
    testInsert_ExistingParentNewChild(parent, bidirChild, startEnd);
  }
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.