Examples of HasKeyPkJDO


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

    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testUpdate_NullOutChild(NEW_PM_START_END);
  }
  private void testUpdate_NullOutChild(StartEnd startEnd) throws EntityNotFoundException {
    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();

    HasOneToOneJDO pojo = new HasOneToOneJDO();
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParent.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);
    String flightId = f.getId();
    Key hasKeyPkKey = hasKeyPk.getKey();
    String hasParentKey = hasParent.getKey();
    Key hasParentKeyPkKey = hasParentKeyPk.getKey();
    startEnd.end();

    startEnd.start();
View Full Code Here

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

  public void testNonTransactionalUpdate() throws EntityNotFoundException {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);

    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();

    HasOneToOneJDO pojo = new HasOneToOneJDO();
    pojo.setFlight(f);
View Full Code Here

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

    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testNewParentNewChild_LongKeyOnParent(NEW_PM_START_END);
  }
  private void testNewParentNewChild_LongKeyOnParent(StartEnd startEnd) throws EntityNotFoundException {
    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneLongPkParentJDO hasParent = new HasOneToOneLongPkParentJDO();
    HasOneToOneLongPkParentKeyPkJDO hasParentKeyPk = new HasOneToOneLongPkParentKeyPkJDO();

    HasOneToOneLongPkJDO pojo = new HasOneToOneLongPkJDO();
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParentKeyPk.setParent(pojo);

    makePersistentInTxn(pojo, startEnd);

    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());
    assertNotNull(pojo.getId());

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertEquals("jimmy", flightEntity.getProperty("name"));
    assertEquals("bos", flightEntity.getProperty("origin"));
    assertEquals("mia", flightEntity.getProperty("dest"));
    assertEquals(2L, flightEntity.getProperty("me"));
    assertEquals(3L, flightEntity.getProperty("you"));
    assertEquals(44L, flightEntity.getProperty("flight_number"));
    assertEquals(KeyFactory.stringToKey(f.getId()), flightEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), flightEntity, f.getId());

    Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
    assertNotNull(hasKeyPkEntity);
    assertEquals(hasKeyPk.getKey(), hasKeyPkEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertEquals(KeyFactory.stringToKey(hasParent.getKey()), hasParentEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), hasParentEntity, hasParent.getKey());
View Full Code Here

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

    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testNewParentNewChild_StringKeyOnParent(NEW_PM_START_END);
  }
  private void testNewParentNewChild_StringKeyOnParent(StartEnd startEnd) throws EntityNotFoundException {
    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneStringPkParentJDO hasParent = new HasOneToOneStringPkParentJDO();
    HasOneToOneStringPkParentKeyPkJDO hasParentKeyPk = new HasOneToOneStringPkParentKeyPkJDO();

    HasOneToOneStringPkJDO pojo = new HasOneToOneStringPkJDO();
    pojo.setId("yar");
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParentKeyPk.setParent(pojo);

    makePersistentInTxn(pojo, startEnd);

    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());
    assertNotNull(pojo.getId());

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertEquals("jimmy", flightEntity.getProperty("name"));
    assertEquals("bos", flightEntity.getProperty("origin"));
    assertEquals("mia", flightEntity.getProperty("dest"));
    assertEquals(2L, flightEntity.getProperty("me"));
    assertEquals(3L, flightEntity.getProperty("you"));
    assertEquals(44L, flightEntity.getProperty("flight_number"));
    assertEquals(KeyFactory.stringToKey(f.getId()), flightEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), flightEntity, f.getId());

    Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
    assertNotNull(hasKeyPkEntity);
    assertEquals(hasKeyPk.getKey(), hasKeyPkEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertEquals(KeyFactory.stringToKey(hasParent.getKey()), hasParentEntity.getKey());
    assertKeyParentEquals(pojo.getClass(), pojo.getId(), hasParentEntity, hasParent.getKey());
View Full Code Here

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

    commitTxn();

  }

  public void testKeyPk_UserProvidedId() throws EntityNotFoundException {
    HasKeyPkJDO pojo = new HasKeyPkJDO();
    pojo.setKey(TestUtils.createKey(pojo, 34));
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    // the fact that this doesn't throw an exception is the test
    ds.get(KeyFactory.createKey(HasKeyPkJDO.class.getSimpleName(), 34));
View Full Code Here

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

    commitTxn();
  }

  public void testEmbeddedWithKeyPk_NotNullEmbedded() {
    HasEmbeddedWithKeyPkJDO pojo = new HasEmbeddedWithKeyPkJDO();
    HasKeyPkJDO embedded = new HasKeyPkJDO();
    embedded.setStr("yar");
    pojo.setEmbedded(embedded);
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    pm.evictAll();
View Full Code Here

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

    HasEmbeddedWithKeyPkJDO pojo = new HasEmbeddedWithKeyPkJDO();
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();

    HasKeyPkJDO embedded = new HasKeyPkJDO();
    embedded.setStr("yar");
    beginTxn();
    pojo.setEmbedded(embedded);
    pojo = pm.getObjectById(HasEmbeddedWithKeyPkJDO.class, pojo.getId());
    pojo.setEmbedded(embedded);
    commitTxn();
View Full Code Here

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

    commitTxn();
  }

  public void testEmbeddingPC() throws EntityNotFoundException {
    HasEmbeddedPc parent = new HasEmbeddedPc();
    HasKeyPkJDO embedded = new HasKeyPkJDO();
    embedded.setKey(KeyFactory.createKey("blar", 43L));
    parent.setEmbedded(embedded);
    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    Entity e = ds.get(parent.getKey());
View Full Code Here

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

  }

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

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

    pojo = pm.makePersistent(pojo);
    assertEquals("yar", pojo.getVal());
    Flight f = newFlight();
    pojo.addFlight(f);

    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    hasKeyPk.setStr("yag");
    pojo.addHasKeyPk(hasKeyPk);
    bidirChild.setChildVal("yam");
    pojo.addBidirChild(bidirChild);
    startEnd.end();

    startEnd.start();
    assertNotNull(bidirChild.getId());
    assertNotNull(bidirChild.getParent());
    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    startEnd.end();
   
    Entity bidirChildEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    assertNotNull(bidirChildEntity);
    assertEquals("yam", bidirChildEntity.getProperty("childVal"));
    assertEquals(KeyFactory.stringToKey(bidirChild.getId()), bidirChildEntity.getKey());
    assertKeyParentEquals(pojo.getId(), bidirChildEntity, bidirChild.getId());
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, bidirChildEntity.getProperty("bidirChildren_INTEGER_IDX"));
    }

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertEquals("bos", flightEntity.getProperty("origin"));
    assertEquals("mia", flightEntity.getProperty("dest"));
    assertEquals("jimmy", flightEntity.getProperty("name"));
    assertEquals(KeyFactory.stringToKey(f.getId()), flightEntity.getKey());
    assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, flightEntity.getProperty("flights_INTEGER_IDX"));
    }

    Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
    assertNotNull(hasKeyPkEntity);
    assertEquals("yag", hasKeyPkEntity.getProperty("str"));
    assertEquals(hasKeyPk.getKey(), hasKeyPkEntity.getKey());
    assertKeyParentEquals(pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, hasKeyPkEntity.getProperty("hasKeyPks_INTEGER_IDX"));
    }

    Entity parentEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.