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

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


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

  public void testOneToOnePersistCascadePersist() throws EntityNotFoundException {
    HasOneToOnesWithDifferentCascadesJDO parent = new HasOneToOnesWithDifferentCascadesJDO();
    HasStringAncestorKeyPkJDO child = new HasStringAncestorKeyPkJDO();
    parent.setCascadePersistChild(child);

    beginTxn();
    pm.makePersistent(parent);
    commitTxn();

    beginTxn();
    parent = pm.getObjectById(HasOneToOnesWithDifferentCascadesJDO.class, parent.getId());
    child = pm.getObjectById(HasStringAncestorKeyPkJDO.class, child.getKey());
    assertEquals(parent.getId(), child.getAncestorKey());
    assertNotNull(parent.getCascadePersistChild());
    commitTxn();

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


    HasOneToOnesWithDifferentCascadesJDO anotherParent = new HasOneToOnesWithDifferentCascadesJDO();
    beginTxn();
    pm.makePersistent(anotherParent);
    commitTxn();

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

    beginTxn();
    try {
      pm.makePersistent(parent);
View Full Code Here

  }

  public void testInsertWithKeyPkAndStringAncestor_IdGen() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasStringAncestorKeyPkJDO hk1 = new HasStringAncestorKeyPkJDO();
    hk1.setAncestorKey(KeyFactory.keyToString(e.getKey()));
    beginTxn();
    pm.makePersistent(hk1);
    Key key = hk1.getKey();
    String ancestorKey = hk1.getAncestorKey();
    commitTxn();
    Entity reloaded = ds.get(key);
    assertEquals(ancestorKey, KeyFactory.keyToString(reloaded.getKey().getParent()));
  }
View Full Code Here

  }

  public void testInsertWithKeyPkAndStringAncestor_NamedKey() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasStringAncestorKeyPkJDO hk1 = new HasStringAncestorKeyPkJDO();
    Key key = new Entity(HasStringAncestorKeyPkJDO.class.getSimpleName(), "named key", e.getKey()).getKey();
    hk1.setKey(key);
    beginTxn();
    pm.makePersistent(hk1);
    assertEquals(e.getKey(), KeyFactory.stringToKey(hk1.getAncestorKey()));
    String ancestorKey = hk1.getAncestorKey();
    commitTxn();
    Entity reloaded = ds.get(key);
    assertEquals(ancestorKey, KeyFactory.keyToString(reloaded.getKey().getParent()));
  }
View Full Code Here

  }

  public void testInsertWithKeyPkAndStringAncestor_SetKeyAndAncestor() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasStringAncestorKeyPkJDO hk1 = new HasStringAncestorKeyPkJDO();
    Key key = KeyFactory.createKey(HasStringAncestorKeyPkJDO.class.getSimpleName(), "named key");
    hk1.setKey(key);
    hk1.setAncestorKey(KeyFactory.keyToString(e.getKey()));
    beginTxn();
    try {
      pm.makePersistent(hk1);
      fail("expected exception");
    } catch (JDOFatalUserException ex) {
View Full Code Here

    ds.put(parent);
    Entity child = new Entity(HasStringAncestorKeyPkJDO.class.getSimpleName(), parent.getKey());
    ds.put(child);
    commitTxn();
    beginTxn();
    HasStringAncestorKeyPkJDO hk =
        pm.getObjectById(HasStringAncestorKeyPkJDO.class, child.getKey());
    assertNotNull(hk.getKey());
    assertEquals(parent.getKey(), KeyFactory.stringToKey(hk.getAncestorKey()));
  }
View Full Code Here

TOP

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

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.