NucleusObjectNotFoundException

106 views
Skip to first unread message

nikhil dhankani

unread,
Nov 11, 2013, 10:14:38 PM11/11/13
to google-a...@googlegroups.com
Hi,

I am getting the below exception even when I have the entity with Id 4 for the kind X.

Could not retrieve entity of kind X with key X("X(4)")
org.datanucleus.exceptions.NucleusObjectNotFoundException: Could not retrieve entity of kind X with key X("X(4)")
at com.google.appengine.datanucleus.DatastoreExceptionTranslator.wrapEntityNotFoundException(DatastoreExceptionTranslator.java:61)
at com.google.appengine.datanucleus.EntityUtils.getEntityFromDatastore(EntityUtils.java:670)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:543)
at org.datanucleus.state.JDOStateManager.loadFieldsFromDatastore(JDOStateManager.java:1638)
at org.datanucleus.state.JDOStateManager.validate(JDOStateManager.java:3511)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:3379)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1722)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1740)
        ...................

Below is the structure of Kind X,

@PersistenceCapable

class X {
@PrimaryKey
 
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 
private Key xId;

 
// getter setter for xId and other attributes
}

I am trying to retrieve this using below code,

getX(String id){
PersistenceManager pm = PMF.get().getPersistenceManager();
 
...
 
Key k = KeyFactory.createKey(X.class.getSimpleName(), id);
 
X x = pm.getObjectById(X.class, k);
 
//X x = pm.getObjectById(X.class, id);  // Even this does not work
 
return x;
 
...
}

I am sure I am doing some silly and basic mistake here. Can someone out here figure out as to what am I doing wrong over here ?

Thanks !


Ian Marshall

unread,
Nov 12, 2013, 5:55:58 AM11/12/13
to google-a...@googlegroups.com
This sort of question is ideal to be asked on StackOverflow.

Vinny P

unread,
Nov 13, 2013, 1:53:07 AM11/13/13
to google-a...@googlegroups.com
On Mon, Nov 11, 2013 at 9:14 PM, skin <nikhild...@gmail.com> wrote:
I am getting the below exception even when I have the entity with Id 4 for the kind X.
Could not retrieve entity of kind X with key X("X(4)")
org.datanucleus.exceptions.NucleusObjectNotFoundException: Could not retrieve entity of kind X with key X("X(4)")



If you query the datastore for this entity using a property search, does this entity show up in the query results?
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
  

nikhil dhankani

unread,
Nov 13, 2013, 3:38:55 AM11/13/13
to google-a...@googlegroups.com
Yes, it does show up. Strangely, this is not just happening to this particular id but to all entities in this Kind.


--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/mzIuSECXPdQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Vinny P

unread,
Nov 13, 2013, 9:02:25 AM11/13/13
to google-a...@googlegroups.com
On Wed, Nov 13, 2013 at 2:38 AM, nikhil dhankani <nikhild...@gmail.com> wrote:
Yes, it does show up. Strangely, this is not just happening to this particular id but to all entities in this Kind.


 

Instead of using a Key instance, can you use a Long as the entity's primary key and see if you can extract the entity? Here's an example: https://developers.google.com/appengine/docs/java/datastore/jdo/creatinggettinganddeletingdata#Keys

nikhil dhankani

unread,
Nov 13, 2013, 9:53:51 AM11/13/13
to google-a...@googlegroups.com
I cannot use Long or String as the key because this is referred in another Kind. I will have try with key with encoding.


nikhil dhankani

unread,
Nov 13, 2013, 1:56:34 PM11/13/13
to google-a...@googlegroups.com
So using encodedKey and post at http://stackoverflow.com/a/2761961/563746 helped. Issue was Kind X was being used in Kind Y with a one to many relation.

But I still fail to understand that why would it not get me the object when it is there ? What can be the issue there ?

Reply all
Reply to author
Forward
0 new messages