Hi,
In my application, I have the following unidirectional one-to-many
relationship:
@PersistenceCapable
public class Recipe implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
....
}
@PersistenceCapable
public class CookBook {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String title;
@Persistent
private List<Recipe> recipes; // *<- one to many with Recipe *
....
}
I am doing the following to persist an instance of *CookBook* into data
store using the low level API:
private DatastoreService dataStoreSvc =
DatastoreServiceFactory.getDatastoreService();
public void persistEntity(CookBook cookBook) {
Entity entityToPersist = new Entity("CookBook");
...
entityToPersist.setProperty("recipes", cookBook.getRecipes()); // *<--
an error occurs here*
...
dataStoreSvc.put(entityToPersist);
}
In the snippet above, the highlighted line throws the following error:
recipes: com.examples.domain.Recipe is not a supported property type.
java.lang.IllegalArgumentException: recipes: com.examples.domain.Recipe is
not a supported property type.
at
com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184)
at
com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:149)
at
com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:123)
at
com.google.appengine.api.datastore.Entity.setProperty(Entity.java:280)
at
com.examples.domain.persist.DatastoreHelper.persistEntity(DatastoreHelper.java:21)
Note that I marked the *Recipe* class to be Serializable &
PersistanceCapable. Still the *setProperty* call fails. Moreover, I am using
this snippet of code (and the low level API) during local unit testing and
my test fails with this error.
Could you please help me understand what am I missing here ? Please let me
know if you need more information.
Sincere Regards,
Kalyan
--
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.