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

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


  }

  public void testInsertWithKeyPkAndKeyAncestor_IdGen() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasKeyAncestorKeyPkJPA hk1 = new HasKeyAncestorKeyPkJPA();
    hk1.setAncestorKey(e.getKey());
    beginTxn();
    em.persist(hk1);
    commitTxn();

    Entity reloaded = ds.get(hk1.getKey());
    assertEquals(hk1.getAncestorKey(), reloaded.getKey().getParent());
  }
View Full Code Here


  }

  public void testInsertWithKeyPkAndKeyAncestor_NamedKey() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasKeyAncestorKeyPkJPA hk1 = new HasKeyAncestorKeyPkJPA();
    Key keyToSet =
        new Entity(HasKeyAncestorKeyPkJPA.class.getSimpleName(), "yar", e.getKey()).getKey();
    hk1.setKey(keyToSet);
    beginTxn();
    em.persist(hk1);
    commitTxn();
    Key key = hk1.getKey();
    assertEquals(e.getKey(), hk1.getAncestorKey());
    Entity reloaded = ds.get(key);
    assertEquals(e.getKey(), reloaded.getKey().getParent());
  }
View Full Code Here

  }

  public void testInsertWithKeyPkAndKeyAncestor_SetAncestorAndPk() throws EntityNotFoundException {
    Entity parentEntity = new Entity("yam");
    ds.put(parentEntity);
    HasKeyAncestorKeyPkJPA hk1 = new HasKeyAncestorKeyPkJPA();
    Key keyToSet =
        new Entity(HasKeyAncestorKeyPkJPA.class.getSimpleName(), "yar", parentEntity.getKey()).getKey();
    hk1.setKey(keyToSet);
    hk1.setAncestorKey(keyToSet);
    beginTxn();
    em.persist(hk1);
    try {
      commitTxn();
      fail("expected exception");
View Full Code Here

  }

  public void testOneToOnePersistCascadeRemove() throws EntityNotFoundException {
    switchDatasource(EntityManagerFactoryName.nontransactional_ds_non_transactional_ops_not_allowed);

    HasKeyAncestorKeyPkJPA child = new HasKeyAncestorKeyPkJPA();

    beginTxn();
    em.persist(child);
    commitTxn();
    HasOneToOnesWithDifferentCascadesJPA parent = new HasOneToOnesWithDifferentCascadesJPA();
    parent.setCascadeRemoveChild(child);
    beginTxn();
    em.persist(parent);
    try {
      commitTxn();
      fail("expected exception");
    } catch (PersistenceException e) {
      // good
      rollbackTxn();
    }

    Entity childEntity = ds.get(child.getKey());
    assertKeyParentNull(childEntity, childEntity.getKey());
  }
View Full Code Here

TOP

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

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.