Hello Guys, I am trying to build a relatively simple application on Google App Engine. I am trying to use JDO to build my datalayer and am running into a load of issues. I am very new to JDO so these might be newbie issues, but I cant seem to proceed past this.
The problem is that when i try to access an object via getObjectByID and I create a User key to pass to the function, I was getting different errors at different times. 1. Error while trying to convert <stringified primary key object> into internal key 2. Object not found The detailed steps I performed are as follows: 1. Created a New Google App Engine Project 2. Created a new Entity: User (Code attached) (fields: firstName, lastName, emailID) 3. Created a primaryKey: UserPK (on emailID ) // I know that i could use the default key, but i need to do this way 4. Stored it vi User user = new User(....., "t...@example.com"); pm.makePersistent(user) 5. Trying to access it by: UserPK pk = new UserPK("com.basildsouza.odometer.datalayer.dataobjects.User$ UserPK::t...@example.com <userpk%3a%3at...@example.com>") pm.getObjectById(pk) // This doesnt work, was initially giving my error 1 (see above) and now gives me error 2 Also when i run a query like select from ...User where emailID= t...@example.com, it does find the value properly, so i am at a loss as to why the getObjectById isnt working. Also, when i do pm.deletePersistant on an object i got via my above query, i get an error saying that the primary key is null. What i have understood from this, is that for some reason the primary key isnt getting set for the user object. But i dont know why. Please Help! Code Attached: User.java (with the UserPK as an inner static class) (Pardon the mess :) jdoconfig.xml (generated by google) -- Regards, Basil Dsouza http://www.basildsouza.com
<?xml version="1.0" encoding="utf-8"?> <jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig"> <persistence-manager-factory name="transactions-optional"> <property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/> <property name="javax.jdo.option.ConnectionURL" value="appengine"/> <property name="javax.jdo.option.NontransactionalRead" value="true"/> <property name="javax.jdo.option.NontransactionalWrite" value="true"/> <property name="javax.jdo.option.RetainValues" value="true"/> <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/> </persistence-manager-factory> </jdoconfig>