Hi all!
I'm trying to learn AppEngine and I'm having a frustrating problem
(most likely caused by NOT Reading TFM) here's my issue:
I have a Class User that has a 1-many relationship with contacts
@PersistenceCapable
@FetchGroup(name = "_contacts", members = { @Persistent(name =
"contacts") })
public class User {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String avatar;
@Persistent
private String userLink;
@Persistent(mappedBy = "user")
private List<Contact> contacts;
...
}
And
@PersistenceCapable
@FetchGroup(name = "_user", members = { @Persistent(name =
"user"), @Persistent(name = "otherData") })
public class Contact {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long key;
@Persistent
private User user;
@Persistent
private Date creationDate;
@Persistent
private MoreData otherData;
@Persistent
private String description;
...
}
Basically my issue is: if I do
public Contact getContact(Long contactId) {
PersistenceManager pm = getPMF();
try {
Contact obj2 = pm.getObjectById(Contact.class,
contactId);
return obj2;
} finally {
pm.close();
}
}
I get
Caused by: org.datanucleus.exceptions.NucleusObjectNotFoundException:
Could not retrieve entity of kind Contact with key Contact(5)
at
org.datanucleus.store.appengine.DatastoreExceptionTranslator.wrapEntityNotFoundException(DatastoreExceptionTranslator.java:
60)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.get(DatastorePersistenceHandler.java:
100)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.get(DatastorePersistenceHandler.java:
106)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:
478)
at
org.datanucleus.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:
4263)
at
org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:
2444)
but If I do a query without filters I can get the list of all
Contacts, I can see it with the right ID, but if I search it with
getObjectById it fails
I also tried to search users by ID and that worked... so I suppose
that there is something wrong with the relationship declaration ...
but I'm not sure what.
Any Idea (appart from RTFM :D )?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.