What steps will reproduce the problem?
A test case like this (in JDOFetchTest) won't work:
public void testSimpleFetch_NamedKey_NameOnly_NewObjectIdInstance() {
Key key = ds.put(Flight.newFlightEntity("named key", "1", "yam", "bam", 1, 2));
commitTxn();
beginTxn();
Flight flight = (Flight) pm.getObjectById(pm.newObjectIdInstance(Flight.class, "named key"));
assertNotNull(flight);
assertEquals(KeyFactory.keyToString(key), flight.getId());
assertEquals("named key", KeyFactory.stringToKey(flight.getId()).getName());
}
What is the expected output? What do you see instead?
pm.getObjectById(Class cls, Object key) should behave the same as
pm.getObjectById(pm.newObjectIdInstance(Class cls, Object key)) but it doesn't.
Test stack trace:
java.lang.IllegalArgumentException: Invalid Key PB: no elements.
at com.google.appengine.api.datastore.KeyTranslator.createFromPb(KeyTranslator.java:26)
at com.google.appengine.api.datastore.KeyFactory.stringToKey(KeyFactory.java:197)
at org.datanucleus.store.appengine.EntityUtils.getPkAsKey(EntityUtils.java:160)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.getPkAsKey(DatastorePersistenceHandler.java:488)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:516)
at org.datanucleus.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:4263)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2444)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1671)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1652)
at org.datanucleus.store.appengine.JDOFetchTest.testSimpleFetch_NamedKey_NameOnly_NewObjectIdInstance(JDOFetchTest.java:155)
What version of the product are you using? On what operating system?
I'm using datanucleus-appengine from SVN trunk, rev 489 (version 1.0.9.final)
Please provide any additional information below.
Probably PersistenceManager.newObjectIdInstance() should be overridden instead
of pm.getObjectById. Or an IdentityTranslator could be used, maybe.
Original issue reported on code.google.com by cairomas...@gmail.com on 1 Jun 2011 at 3:59
Original issue reported on code.google.com by
cairomas...@gmail.com
on 1 Jun 2011 at 3:59Attachments: