Examples of HasKeyPkJDO


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

  public void testChangeKeyPK_SetDifferentKey() throws EntityNotFoundException {
    Key key = ds.put(new Entity(HasKeyPkJDO.class.getSimpleName()));

    beginTxn();
    HasKeyPkJDO pojo = pm.getObjectById(HasKeyPkJDO.class, key);

    pojo.setKey(KeyFactory.createKey(HasKeyPkJDO.class.getSimpleName(), 33));
    try {
      commitTxn();
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

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

  }

  public void testChangeKeyPK_SetNull() throws EntityNotFoundException {
    Key key = ds.put(new Entity(HasKeyPkJDO.class.getSimpleName()));
    beginTxn();
    HasKeyPkJDO pojo = pm.getObjectById(HasKeyPkJDO.class, key);
    pojo.setKey(null);
    try {
      commitTxn();
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

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

      pmf.close();
      switchDatasource(startEnd.getPmfName());
      Flight flight = new Flight();
      pojo.setFlight(flight);
      pojo.setHasParent(hasParent);
      HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
      pojo.setHasKeyPK(hasKeyPk);

      startEnd.start();
      pm.makePersistent(pojo);
      startEnd.end();
View Full Code Here

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

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

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

    makePersistentInTxn(pojo, startEnd);

    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());
    assertNotNull(notDependent.getId());
    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.getId(), flightEntity, f.getId());

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

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertEquals(KeyFactory.stringToKey(hasParent.getKey()), hasParentEntity.getKey());
    assertKeyParentEquals(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);
    testInsert_NewParentExistingChild_Unidirectional(NEW_PM_START_END);
  }
  private void testInsert_NewParentExistingChild_Unidirectional(StartEnd startEnd) throws EntityNotFoundException {
    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();

    startEnd.start();
    pm.makePersistent(f);
    startEnd.end();
    startEnd.start();
    pm.makePersistent(hasKeyPk);
    startEnd.end();
    startEnd.start();
    pm.makePersistent(hasParent);
    startEnd.end();
    startEnd.start();
    pm.makePersistent(hasParentKeyPk);
    startEnd.end();
    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());

    HasOneToOneJDO pojo = new HasOneToOneJDO();
View Full Code Here

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

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

    makePersistentInTxn(f, startEnd);
    makePersistentInTxn(hasKeyPk, startEnd);
    makePersistentInTxn(hasParent, startEnd);
    makePersistentInTxn(hasParentKeyPk, startEnd);
    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());

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

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

   
    Entity pojoEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
    assertNotNull(pojoEntity);

    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();
    startEnd.start();
    pojo = pm.makePersistent(pojo);
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParent.setParent(pojo);
    startEnd.end();

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

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());

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

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

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

    Entity pojoEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
    assertNotNull(pojoEntity);

    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();
    startEnd.start();
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParent.setParent(pojo);
    pojo = pm.makePersistent(pojo);
    startEnd.end();

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

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());

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

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertKeyParentEquals(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);
    testUpdate_UpdateChildWithMerge(NEW_PM_START_END);
  }
  private void testUpdate_UpdateChildWithMerge(StartEnd startEnd) throws EntityNotFoundException {
    Flight f = newFlight();
    HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();

    HasOneToOneJDO pojo = new HasOneToOneJDO();
    pojo.setFlight(f);
    pojo.setHasKeyPK(hasKeyPk);

    HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
    pojo.setHasParent(hasParent);
    hasParent.setParent(pojo);

    HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();
    pojo.setHasParentKeyPK(hasParentKeyPk);
    hasParent.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);

    assertNotNull(f.getId());
    assertNotNull(hasKeyPk.getKey());
    assertNotNull(hasParent.getKey());
    assertNotNull(hasParentKeyPk.getKey());
    assertNotNull(pojo.getId());
    f = pm.detachCopy(f);
    hasKeyPk = pm.detachCopy(hasKeyPk);
    hasParent = pm.detachCopy(hasParent);
    hasParentKeyPk = pm.detachCopy(hasParentKeyPk);
    startEnd.end();
    startEnd.start();
    f.setOrigin("yam");
    hasKeyPk.setStr("yar");
    hasParent.setStr("yag");
    hasParentKeyPk.setStr("yap");
    f = pm.makePersistent(f);
    hasKeyPk = pm.makePersistent(hasKeyPk);
    hasParent = pm.makePersistent(hasParent);
    hasParentKeyPk = pm.makePersistent(hasParentKeyPk);
    startEnd.end();

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertEquals("yam", flightEntity.getProperty("origin"));
    assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());

    Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
    assertNotNull(hasKeyPkEntity);
    assertEquals("yar", hasKeyPkEntity.getProperty("str"));
    assertKeyParentEquals(pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertEquals("yag", hasParentEntity.getProperty("str"));
    assertKeyParentEquals(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);
    testUpdate_UpdateChild(NEW_PM_START_END);
  }
  public void testUpdate_UpdateChild(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);

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

    startEnd.start();
    pojo = pm.getObjectById(HasOneToOneJDO.class, pojo.getId());
    pojo.getFlight().setOrigin("yam");
    pojo.getHasKeyPK().setStr("yar");
    pojo.getHasParent().setStr("yag");
    pojo.getHasParentKeyPK().setStr("yap");
    startEnd.end();

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    assertNotNull(flightEntity);
    assertEquals("yam", flightEntity.getProperty("origin"));
    assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());

    Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
    assertNotNull(hasKeyPkEntity);
    assertEquals("yar", hasKeyPkEntity.getProperty("str"));
    assertKeyParentEquals(pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());

    Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
    assertNotNull(hasParentEntity);
    assertEquals("yag", hasParentEntity.getProperty("str"));
    assertKeyParentEquals(pojo.getId(), hasParentEntity, hasParent.getKey());
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.