Hi, I have a question on nested Entity class using JPA framework on appengine. I have code liek this..
@Entity public class MyDataObject { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Key key; // some persistent fields of standatd types @Basic @OneToOne(cascade={CascadeType.PERSIST,CascadeType.REFRESH,CascadeType.REMOVE}) List<SmartItem>data; // standard getters/setters } One of the fields above is "data" which is a collection of a another Entity class SmartItem. @Entity public class SmartItem implements java.io.Serializable{ private static final long serialVersionUID = 4428700412206745337L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Key key; public Key getKey() { return key; } //bunch of persistent fields } Key key = KeyFactory.createKey(MyDataObject.class.getSimpleName(), newData.deviceId); newData.key = key; em.persist(newData); //em.merge(newData); When I call em.persist for first time, the data is saved correctly. I see a list of my "SmartItem" objects in the datastore. When I call em.persist again for the same entiry MyDataObject, the SmartItems are "appended" and not "replaced". Ex: First item I have my <List> data as "list1", "list2". Next I add "list3" to my list and call em.persist(..). Now I see "list1", "list2", "list1", "list2", "list3" items. Tried em.merge and still same behavior. Anyone has suggestions? When I call em.persist(), I would like my nested Entity field item List<SmartItem> data to just contain the new list and not the old entities.. Thanks Neeli -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/jw2M2-7kSucJ. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.