[google-appengine] JDOObjectNotFound exception when using getObjectById
Hi All, I am stuck with a very weird case here while using getObjectById() function, I have a persistent class called Category and i am saving it to appengine datastore using JDO. I have tried to fetch a particular entry using query and getObjectById() method, the query is passing and returning me the correct results but getObjectById is throwing exception JDOObjectNotFound. The Category class have a primary key field called id, a parent key and a child key. the child and parent are actually primary key of other Category instances.( I am trying to buuld a heirarchy of similar objects here. I am using unowned one to many relationship here.) // In following code we get the Id of parent and remove the child's information from it. Long id = e.getParent(); // returns parent Id. Query query = pm.newQuery(Category.class); query.setFilter(id == cat_id); // get the Category with primary key id = cat_id. query.declareParameters(Long cat_id); ListCategory results = (ListCategory) query.execute(id); // get parent category. results contain the expected information. if (results.iterator().hasNext()) { for (Category e3 : results) { SetLong child = e3.getChildrens(); // get the childrens. } } Category e2 = (Category) pm.getObjectById(id); // throws JDOObjectNotFound exception. It is expected to contain the same information as in results 1st element. e2.removeChildren(e.getId()); pm.deletePersistent(e); As you must have seen in the code i am fetching same id using the query and it returning me the expected objects while the getObjectById is throwing the exception JDOObjectNotFound. Any clues why it is throwing that exception. I tried to google it but could not find any obvious reason, Can somebody help me figuring out where I am doing it wrong. Regards, Vijay --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] JDOObjectNotFound exception when using getObjectById
Hi All, I am stuck with a very weird case here while using getObjectById() function, I have a persistent class called Category and i am saving it to appengine datastore using JDO. I have tried to fetch a particular entry using query and getObjectById() method, the query is passing and returning me the correct results but getObjectById is throwing exception JDOObjectNotFound. The Category class have a primary key field called id, a parent key and a child key. the child and parent are actually primary key of other Category instances.( I am trying to buuld a heirarchy of similar objects here. I am using unowned one to many relationship here.) // In following code we get the Id of parent and remove the child's information from it. Long id = e.getParent(); // returns parent Id. Query query = pm.newQuery(Category.class); query.setFilter(id == cat_id); // get the Category with primary key id = cat_id. query.declareParameters(Long cat_id); ListCategory results = (ListCategory) query.execute(id); // get parent category. results contain the expected information. if (results.iterator().hasNext()) { for (Category e3 : results) { SetLong child = e3.getChildrens(); // get the childrens. } } Category e2 = (Category) pm.getObjectById(id); // throws JDOObjectNotFound exception. It is expected to contain the same information as in results 1st element. e2.removeChildren(e.getId()); pm.deletePersistent(e); As you must have seen in the code i am fetching same id using the query and it returning me the expected objects while the getObjectById is throwing the exception JDOObjectNotFound. Any clues why it is throwing that exception. I tried to google it but could not find any obvious reason, Can somebody help me figuring out where I am doing it wrong. Regards, Vijay --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google App Engine group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---