OverclockedTim
OverclockedTim

Reputation: 1743

JDO doesn't create Owned Entities in Google App Engine

Hey guys, my question is about persisting an entity in JDO. I have created a class, StoredOPDSFeed, whose members persist correctly. However, none of its member objects persist correctly. The class is as follows:

@PersistenceCapable
public class StorableOPDSFeed implements Serializable {

private static final long serialVersionUID = 1L;

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private String primaryKey;

@Persistent
private String locale;

@Persistent
private Date parseDate;

@Persistent
private String title;

@Persistent
private String href;

@Persistent
@Element(dependent = "true")
private ArrayList<OPDSEntry> entries;

@Persistent
@Element(dependent = "true")
private ArrayList<OPDSLink> links = new ArrayList<OPDSLink>();

@Persistent
@Embedded
private SearchDescription searchDescription;

@Persistent
private boolean isStart = false;

@Persistent
@Element(dependent = "true")
private ArrayList<OPDSFacetGroup> facet_groups = new ArrayList<OPDSFacetGroup>();

... and accessors, etc.
}

All of the simple members such as locale, title, href, etc persist correctly. However, all of the complex ones such as searchDescription do not appear in the datastore. There is no reference to them whatsoever, no foreign key, nothing. It's like they are completely ignored. Does anyone have any idea why?

Per request, here is the code for OPDSLink:

@PersistenceCapable
public class OPDSLink implements Serializable { 
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
private String encodedKey;

private static final long serialVersionUID = 1L;

@Persistent
private String href;

@Persistent
private String rel;

@Persistent
private String type;

@Persistent
private String price;

@Persistent
private String currency;

@Persistent
private String dcformat;

@Persistent
private String title;
... and accessors, etc.
}

Upvotes: 1

Views: 564

Answers (1)

Arno Fiva
Arno Fiva

Reputation: 1539

The GAE JDO documentation states that in one-to-one relationships both involved entities require a key field. http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html#Owned_One_to_One_Relationships

If the other entity is embedded as intended in your example, the other class (e.g. SearchDescription) requires a @EmbeddedOnly annotation: http://code.google.com/appengine/docs/java/datastore/jdo/dataclasses.html#Embedded_Classes

In general I found the the following blog interview a good starting point to see what the GAE JDO implementation supports and what not (especially in comparison to third party frameworks such as Objectify and Twig): http://borglin.net/gwt-project/?page_id=604

Upvotes: 2

Related Questions