public void testUnencodedStringPk_BatchGet() throws EntityNotFoundException { switchDatasource(PersistenceManagerFactoryName.nontransactional); HasUnencodedStringPkJDO pojo = new HasUnencodedStringPkJDO(); beginTxn(); pojo.setId("yar1"); pm.makePersistent(pojo); commitTxn(); HasUnencodedStringPkJDO pojo2 = new HasUnencodedStringPkJDO(); beginTxn(); pojo2.setId("yar2"); pm.makePersistent(pojo2); commitTxn(); assertNotNull(pojo.getId()); assertNotNull(pojo2.getId()); beginTxn(); Query q = pm.newQuery("select from " + HasUnencodedStringPkJDO.class.getName() + " where id == :ids"); List<HasUnencodedStringPkJDO> pojos = (List<HasUnencodedStringPkJDO>) q.execute(Utils.newArrayList(pojo.getId(), pojo2.getId())); assertEquals(2, pojos.size()); // we should preserve order but right now we don't Set<String> pks = Utils.newHashSet(pojos.get(0).getId(), pojos.get(1).getId()); assertEquals(pks, Utils.newHashSet("yar1", "yar2")); commitTxn(); }
public void testUnencodedStringPk() throws EntityNotFoundException { HasUnencodedStringPkJDO pojo = new HasUnencodedStringPkJDO(); pojo.setId("a name"); beginTxn(); pm.makePersistent(pojo); commitTxn(); assertEquals("a name", pojo.getId()); Entity e = ds.get(KeyFactory.createKey(HasUnencodedStringPkJDO.class.getSimpleName(), pojo.getId())); beginTxn(); pm.getObjectById(HasUnencodedStringPkJDO.class, e.getKey().getName()); pm.getObjectById(HasUnencodedStringPkJDO.class, e.getKey()); pm.getObjectById(HasUnencodedStringPkJDO.class, KeyFactory.keyToString(e.getKey())); commitTxn(); }