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

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


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

  public void testOneToOnePersistChildWithAncestorCascadeAll() throws EntityNotFoundException {
    HasOneToOnesWithDifferentCascadesJPA parent = new HasOneToOnesWithDifferentCascadesJPA();
    HasStringAncestorStringPkJPA child = new HasStringAncestorStringPkJPA();
    parent.setCascadeAllChild(child);

    beginTxn();
    em.persist(parent);
    commitTxn();

    assertEquals(parent.getId(), child.getAncestorId());

    Entity childEntity = ds.get(KeyFactory.stringToKey(child.getId()));
    assertKeyParentEquals(parent.getId(), childEntity, childEntity.getKey());

    ds.get(KeyFactory.stringToKey(parent.getId()));
  }
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

    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");
View Full Code Here

    Entity childEntity = ds.get(child.getKey());
    assertKeyParentNull(childEntity, childEntity.getKey());
  }

  public void testOneToOnePersistCascadeAll_OverrideParentManually() {
    HasOneToOnesWithDifferentCascadesJPA parent = new HasOneToOnesWithDifferentCascadesJPA();

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

    HasStringAncestorStringPkJPA child = new HasStringAncestorStringPkJPA(anotherParent.getId());
    parent.setCascadeAllChild(child);

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

      // good
    }
  }

  public void testOneToOnePersistCascadePersist_OverrideParentManually() {
    HasOneToOnesWithDifferentCascadesJPA parent = new HasOneToOnesWithDifferentCascadesJPA();

    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

    ds.put(childEntity);
    parentEntity.setProperty("cascadeall", childEntity.getKey());
    ds.put(parentEntity);

    beginTxn();
    HasOneToOnesWithDifferentCascadesJPA parent = em.find(
        HasOneToOnesWithDifferentCascadesJPA.class, KeyFactory.keyToString(parentEntity.getKey()));
    assertNotNull(parent.getCascadeAllChild());
    em.remove(parent);
    commitTxn();

    try {
      ds.get(parentEntity.getKey());
View Full Code Here

    ds.put(childEntity);
    parentEntity.setProperty("cascadeall", childEntity.getKey());
    ds.put(parentEntity);

    beginTxn();
    HasOneToOnesWithDifferentCascadesJPA parent = em.find(
        HasOneToOnesWithDifferentCascadesJPA.class, KeyFactory.keyToString(parentEntity.getKey()));
    assertNotNull(parent.getCascadeAllChild());
    assertKeyParentEquals(parent.getId(), childEntity, parent.getCascadeAllChild().getId());
    em.remove(parent.getCascadeAllChild());
    commitTxn();

    parentEntity = ds.get(parentEntity.getKey());
    assertEquals(childEntity.getKey(), parentEntity.getProperty("cascadeall"));
    try {
View Full Code Here

    ds.put(childEntity);
    parentEntity.setProperty("cascaderemove", childEntity.getKey());
    ds.put(parentEntity);

    beginTxn();
    HasOneToOnesWithDifferentCascadesJPA parent = em.find(
        HasOneToOnesWithDifferentCascadesJPA.class, KeyFactory.keyToString(parentEntity.getKey()));
    assertNotNull(parent.getCascadeRemoveChild());
    assertKeyParentEquals(parent.getId(), childEntity, parent.getCascadeRemoveChild().getKey());
    em.remove(parent.getCascadeRemoveChild());
    commitTxn();

    parentEntity = ds.get(parentEntity.getKey());
    assertEquals(childEntity.getKey(), parentEntity.getProperty("cascaderemove"));
    try {
View Full Code Here

TOP

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

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.