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

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


    pm.getObjectById(HasStringUUIDHexPkJDO.class, KeyFactory.keyToString(e.getKey()));
    commitTxn();
  }

  public void testLongPk() throws EntityNotFoundException {
    HasLongPkJDO pojo = new HasLongPkJDO();
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();

    assertNotNull(pojo.getId());
    Entity e = ds.get(KeyFactory.createKey(HasLongPkJDO.class.getSimpleName(), pojo.getId()));

    beginTxn();
    pm.getObjectById(HasLongPkJDO.class, e.getKey().getId());
    pm.getObjectById(HasLongPkJDO.class, e.getKey());
    pm.getObjectById(HasLongPkJDO.class, KeyFactory.keyToString(e.getKey()));
View Full Code Here


    pm.getObjectById(HasLongPkJDO.class, KeyFactory.keyToString(e.getKey()));
    commitTxn();
  }

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

    // the fact that this doesn't throw an exception is the test
    ds.get(KeyFactory.createKey(HasKeyPkJDO.class.getSimpleName(), 34));
  }

  public void testCannotChangeLongPk() {
    HasLongPkJDO pojo = new HasLongPkJDO();
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    beginTxn();
    pojo = pm.getObjectById(HasLongPkJDO.class, pojo.getId());
    pojo.setId(88L);
    try {
      commitTxn();
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

    commitTxn();
  }

  public void testUnencodedLongPk_BatchGet() throws EntityNotFoundException {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    HasLongPkJDO pojo = new HasLongPkJDO();
    beginTxn();
    pojo.setId(1L);
    pm.makePersistent(pojo);
    commitTxn();

    HasLongPkJDO pojo2 = new HasLongPkJDO();
    beginTxn();
    pojo2.setId(2L);
    pm.makePersistent(pojo2);
    commitTxn();

    assertNotNull(pojo.getId());
    assertNotNull(pojo2.getId());

    beginTxn();
    Query q = pm.newQuery("select from " + HasLongPkJDO.class.getName() + " where id == :ids");
    List<HasLongPkJDO> pojos =
        (List<HasLongPkJDO>) q.execute(Utils.newArrayList(pojo.getId(), pojo2.getId()));
    assertEquals(2, pojos.size());
    // we should preserve order but right now we don't
    Set<Long> pks = Utils.newHashSet(pojos.get(0).getId(), pojos.get(1).getId());
    assertEquals(pks, Utils.newHashSet(1L, 2L));
    commitTxn();
View Full Code Here

TOP

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

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.