I am using the local-development version of App Engine's JDO implementation. When I query an object that has contains other objects as embedded fields, the embedded fields are returned as null.
For example, lets say this is the main object that I am persisting:
@PersistenceCapable
public class Branch {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String name;
@Persistent
private Address address;
...
}
and this my embedded object:
@PersistenceCapable(embeddedOnly="true")
public class Address {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String street;
@Persistent
private String city;
...
}
the following code does not retrieve the embedded object:
PersistenceManager pm = MyPersistenceManagerFactory.get().getPersistenceManager();
Branch branch = null;
try {
branch = pm.getObjectById(Branch.class, branchId);
}
catch (JDOObjectNotFoundException onfe) {
// not found
}
catch (Exception e) {
// failed
}
finally {
pm.close();
}
Does anyone have a solution for this? How can I retrieve the Branch object along with its embedded Address field?