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

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


  }

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

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


  }

  public void testInsertWithKeyPkAndStringAncestor_NamedKey() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasStringAncestorKeyPkJPA hk1 = new HasStringAncestorKeyPkJPA();
    Key key = new Entity(HasStringAncestorKeyPkJPA.class.getSimpleName(), "named key", e.getKey()).getKey();
    hk1.setKey(key);
    beginTxn();
    em.persist(hk1);
    commitTxn();
    assertEquals(e.getKey(), KeyFactory.stringToKey(hk1.getAncestorKey()));

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

  }

  public void testInsertWithKeyPkAndStringAncestor_SetKeyAndAncestor() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasStringAncestorKeyPkJPA hk1 = new HasStringAncestorKeyPkJPA();
    Key key = KeyFactory.createKey(HasStringAncestorKeyPkJPA.class.getSimpleName(), "named key");
    hk1.setKey(key);
    hk1.setAncestorKey(KeyFactory.keyToString(e.getKey()));
    beginTxn();
    em.persist(hk1);
    try {
      commitTxn();
      fail("expected exception");
View Full Code Here

    ds.get(KeyFactory.stringToKey(parent.getId()));
  }

  public void testOneToOnePersistCascadePersist() throws EntityNotFoundException {
    HasOneToOnesWithDifferentCascadesJPA parent = new HasOneToOnesWithDifferentCascadesJPA();
    HasStringAncestorKeyPkJPA child = new HasStringAncestorKeyPkJPA();
    parent.setCascadePersistChild(child);

    beginTxn();
    em.persist(parent);
    assertEquals(parent.getId(), child.getAncestorKey());
    commitTxn();

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

    HasOneToOnesWithDifferentCascadesJPA anotherParent = new HasOneToOnesWithDifferentCascadesJPA();
    beginTxn();
    em.persist(anotherParent);
    commitTxn();

    HasStringAncestorKeyPkJPA child = new HasStringAncestorKeyPkJPA();
    child.setAncestorKey(anotherParent.getId());
    parent.setCascadePersistChild(child);

    beginTxn();
    em.persist(parent);
    try {
View Full Code Here

TOP

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

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.