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

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


    switchDatasource(PersistenceManagerFactoryName.transactional);
    Key parentKey = KeyFactory.createKey("yar", 24);
    Key k1 = ds.put(new Entity(HasKeyAncestorKeyPkJDO.class.getSimpleName(), parentKey));
    Key k2 = ds.put(new Entity(HasKeyAncestorKeyPkJDO.class.getSimpleName(), parentKey));
    beginTxn();
    HasKeyAncestorKeyPkJDO child1 = pm.getObjectById(HasKeyAncestorKeyPkJDO.class, k1);
    HasKeyAncestorKeyPkJDO child2 = pm.getObjectById(HasKeyAncestorKeyPkJDO.class, k2);
    pm.deletePersistentAll(child1, child2);
    commitTxn();
    assertEquals(0, countForClass(HasKeyAncestorKeyPkJDO.class));
    assertEquals(1, batchRecorder.batchOps);
  }
View Full Code Here


    assertKeyParentEquals(parent.getId(), childEntity, childEntity.getKey());
  }

  public void testOneToOnePersistCascadeRemove() throws EntityNotFoundException {
    HasOneToOnesWithDifferentCascadesJDO parent = new HasOneToOnesWithDifferentCascadesJDO();
    HasKeyAncestorKeyPkJDO child = new HasKeyAncestorKeyPkJDO();
    parent.setCascadeRemoveChild(child);

    beginTxn();
    pm.makePersistent(child);
    commitTxn();
View Full Code Here

  public void testDeleteHasAncestorPkField() {
    Entity e =
        new Entity(HasKeyAncestorKeyPkJDO.class.getSimpleName(), KeyFactory.createKey("Yam", 24));
    ds.put(e);
    beginTxn();
    HasKeyAncestorKeyPkJDO pojo = pm.getObjectById(HasKeyAncestorKeyPkJDO.class, e.getKey());
    pm.deletePersistent(pojo);
    commitTxn();
  }
View Full Code Here

    Key keyWithParent = KeyFactory.stringToKey(ha.getId());
    assertNull(keyWithParent.getParent());
  }

  public void testKeyPKKeyAncestor_NamedKey() throws EntityNotFoundException {
    HasKeyAncestorKeyPkJDO pojo = new HasKeyAncestorKeyPkJDO();
    Entity flightEntity = Flight.newFlightEntity("parent named key", "max", "bos", "mia", 3, 4);
    ds.put(flightEntity);
    Key flightKey = flightEntity.getKey();
    Key pojoKey = new Entity(HasKeyAncestorKeyPkJDO.class.getSimpleName(), "child named key", flightKey).getKey();
    pojo.setKey(pojoKey);
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    ds.get(pojoKey);
    beginTxn();
    pojo = pm.getObjectById(HasKeyAncestorKeyPkJDO.class, pojoKey);
    assertEquals(pojo.getAncestorKey(), pojoKey.getParent());
    commitTxn();
  }
View Full Code Here

    assertEquals(pojo.getAncestorKey(), pojoKey.getParent());
    commitTxn();
  }

  public void testKeyPKKeyAncestor_NamedKeyWrongKind() throws EntityNotFoundException {
    HasKeyAncestorKeyPkJDO pojo = new HasKeyAncestorKeyPkJDO();
    Entity flightEntity = Flight.newFlightEntity("parent named key", "max", "bos", "mia", 3, 4);
    ds.put(flightEntity);
    Key flightKey = flightEntity.getKey();
    Key pojoKey = new Entity("blarg", "child named key", flightKey).getKey();
    pojo.setKey(pojoKey);
    beginTxn();
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
View Full Code Here

      rollbackTxn();
    }
  }

  public void testKeyPKKeyAncestor_IdGen() throws EntityNotFoundException {
    HasKeyAncestorKeyPkJDO pojo = new HasKeyAncestorKeyPkJDO();
    Entity flightEntity = Flight.newFlightEntity("parent named key", "max", "bos", "mia", 3, 4);
    ds.put(flightEntity);
    Key flightKey = flightEntity.getKey();
    pojo.setAncestorKey(flightKey);
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    ds.get(pojo.getKey());
    beginTxn();
    pojo = pm.getObjectById(HasKeyAncestorKeyPkJDO.class, pojo.getKey());
    assertEquals(pojo.getAncestorKey(), pojo.getKey().getParent());
    commitTxn();
  }
View Full Code Here

    assertEquals(pojo.getAncestorKey(), pojo.getKey().getParent());
    commitTxn();
  }

  public void testKeyPKKeyAncestor_SetAncestorAndKey() throws EntityNotFoundException {
    HasKeyAncestorKeyPkJDO pojo = new HasKeyAncestorKeyPkJDO();
    Entity flightEntity = Flight.newFlightEntity("parent named key", "max", "bos", "mia", 3, 4);
    ds.put(flightEntity);
    Key flightKey = flightEntity.getKey();
    pojo.setAncestorKey(flightKey);
    Key pojoKey = new Entity(HasKeyAncestorKeyPkJDO.class.getSimpleName(), "child named key", flightKey).getKey();
    pojo.setKey(pojoKey);
    beginTxn();
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
View Full Code Here

  }

  public void testMakePersistentAll_Txn_OneEntityGroup() {
    switchDatasource(JDOTestCase.PersistenceManagerFactoryName.transactional);
    Key parentKey = KeyFactory.createKey("yar", 24);
    HasKeyAncestorKeyPkJDO pojo1 = new HasKeyAncestorKeyPkJDO();
    pojo1.setAncestorKey(parentKey);
    HasKeyAncestorKeyPkJDO pojo2 = new HasKeyAncestorKeyPkJDO();
    pojo2.setAncestorKey(parentKey);
    beginTxn();
    pm.makePersistentAll(pojo1, pojo2);
    commitTxn();
    assertEquals(2, countForClass(HasKeyAncestorKeyPkJDO.class));
    assertEquals(1, batchRecorder.batchOps);
View Full Code Here

TOP

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

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.