Examples of HasOneToOneJDO


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

    Key k1 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName(), KeyFactory.createKey("Yar", 43)));
    Key k2 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName(), KeyFactory.createKey("Yar", 43)));
    ds.put(newFlightEntity(k1, 1));
    ds.put(newFlightEntity(k2, 1));
    beginTxn();
    HasOneToOneJDO parent1 = pm.getObjectById(HasOneToOneJDO.class, k1);
    HasOneToOneJDO parent2 = pm.getObjectById(HasOneToOneJDO.class, k2);
    pm.deletePersistentAll(parent1, parent2);
    commitTxn();
    assertEquals(0, countForClass(HasOneToOneJDO.class));
    assertEquals(0, countForClass(Flight.class));
    assertEquals(1, batchRecorder.batchOps);
View Full Code Here

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

    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Key k1 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName()));
    Key k2 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName()));
    ds.put(newFlightEntity(k1, 1));
    ds.put(newFlightEntity(k2, 1));
    HasOneToOneJDO parent1 = pm.getObjectById(HasOneToOneJDO.class, k1);
    HasOneToOneJDO parent2 = pm.getObjectById(HasOneToOneJDO.class, k2);
    pm.deletePersistentAll(parent1, parent2);
    assertEquals(0, countForClass(HasOneToOneJDO.class));
    assertEquals(0, countForClass(Flight.class));
    assertEquals(1, batchRecorder.batchOps);
  }
View Full Code Here

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

    Key k1 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName()));
    Key k2 = ds.put(new Entity(HasOneToOneJDO.class.getSimpleName()));
    ds.put(newFlightEntity(k1, 1));
    ds.put(newFlightEntity(k2, 1));
    beginTxn();
    HasOneToOneJDO parent1 = pm.getObjectById(HasOneToOneJDO.class, k1);
    commitTxn();
    beginTxn();
    HasOneToOneJDO parent2 = pm.getObjectById(HasOneToOneJDO.class, k2);
    commitTxn();
    beginTxn();
    try {
      pm.deletePersistentAll(parent1, parent2);
      fail("expected exception");
View Full Code Here

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

    startEnd.start();
    @SuppressWarnings("unchecked")
    List<HasOneToOneJDO> result =
        (List<HasOneToOneJDO>) q.execute(KeyFactory.keyToString(pojoEntity.getKey()));
    assertEquals(1, result.size());
    HasOneToOneJDO pojo = result.get(0);
    assertNotNull(pojo.getFlight());
    assertEquals("bos", pojo.getFlight().getOrigin());
    assertNotNull(pojo.getHasKeyPK());
    assertEquals("yar", pojo.getHasKeyPK().getStr());
    assertNotNull(pojo.getHasParent());
    assertEquals("yap", pojo.getHasParent().getStr());
    assertNotNull(pojo.getHasParentKeyPK());
    assertEquals("yag", pojo.getHasParentKeyPK().getStr());
    startEnd.end();
  }
View Full Code Here

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

      EasyMock.expect(mockDatastore.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(txn);
      EasyMock.expect(mockDatastore.get(txn, pojoEntity.getKey())).andReturn(pojoEntity);
      EasyMock.replay(mockDatastore);

      beginTxn();
      HasOneToOneJDO pojo = pm.getObjectById(HasOneToOneJDO.class, KeyFactory.keyToString(pojoEntity.getKey()));
      assertNotNull(pojo);
      pojo.getId();
      commitTxn();
    } finally {
      // need to close the pmf before we restore the original datastore service
      pmf.close();
      DatastoreServiceFactoryInternal.setDatastoreService(null);
View Full Code Here

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

    Entity notDependentEntity = new Entity(HasEncodedStringPkJDO.class.getSimpleName(), pojoEntity.getKey());
    ds.put(notDependentEntity);

    startEnd.start();
    HasOneToOneJDO pojo = pm.getObjectById(HasOneToOneJDO.class, KeyFactory.keyToString(pojoEntity.getKey()));
    pm.deletePersistent(pojo);
    startEnd.end();
    assertCountsInDatastore(0, 0);
    assertEquals(1, countForClass(HasEncodedStringPkJDO.class));
  }
View Full Code Here

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

    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);
    hasParentKeyPk.setParent(pojo);

    pm.makePersistent(pojo);

    pm.close();

    assertCountsInDatastore(1, 1);

    pm = pmf.getPersistenceManager();
    pojo = pm.getObjectById(HasOneToOneJDO.class, pojo.getId());
    pojo.setFlight(null);
    pojo.setHasKeyPK(null);
    pojo.setHasParent(null);
    pojo.setHasParentKeyPK(null);
    pm.close();
    pm = pmf.getPersistenceManager();
   
    assertCountsInDatastore(1, 0);
  }
View Full Code Here

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

  private void testChangeParent(StartEnd startEnd) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    Flight f1 = newFlight();

    HasOneToOneJDO pojo = new HasOneToOneJDO();
    pojo.setFlight(f1);
    startEnd.start();
    pm.makePersistent(pojo);
    f1 = pm.detachCopy(f1);
    startEnd.end();

    HasOneToOneJDO pojo2 = new HasOneToOneJDO();
    startEnd.start();
    pojo2.setFlight(f1);
    try {
      pm.makePersistent(pojo2);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

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

    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
    testNewParentNewChild_SetNamedKeyOnChild(NEW_PM_START_END);
  }
  private void testNewParentNewChild_SetNamedKeyOnChild(StartEnd startEnd) throws EntityNotFoundException {
    HasOneToOneJDO pojo = new HasOneToOneJDO();
    Flight f1 = newFlight();
    pojo.setFlight(f1);
    f1.setId(KeyFactory.keyToString(KeyFactory.createKey(Flight.class.getSimpleName(), "named key")));
    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
View Full Code Here

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

  }

  public void testAddAlreadyPersistedChildToParent_NoTxnDifferentPm() {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Flight f1 = new Flight();
    HasOneToOneJDO pojo = new HasOneToOneJDO();
    pm.makePersistent(f1);
    f1 = pm.detachCopy(f1);
    pm.close();
    pm = pmf.getPersistenceManager();
    pojo.setFlight(f1);
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
    }
    pm.close();

    assertEquals(0, countForClass(pojo.getClass()));
    assertEquals(1, countForClass(Flight.class));
  }
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.