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));
 }
  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();
  }
  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()));
    commitTxn();
  }
 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
     rollbackTxn();
   }
 }