When creating an owned one-to-many relationship, in Java, I noticed that there is a difference in the resulting record between using the low level Datastore API and DataNucleus JDO. Not sure if this is intentional or any way to fix it.
For example,
If there are multiple addresses for an employee in the following link:
https://developers.google.com/appengine/docs/java/datastore/entities#Ancestor_Paths
Using the low level datastore api as following, the employee record doesn't show an address column(i.e. property):
Entity employee = new Entity("Employee");
datastore.put(employee);
Entity address_home = new Entity("Address", employee.getKey());
datastore.put(address_home);
Entity address_mailing = new Entity("Address", employee.getKey());
datastore.put(address_mailing);
Using JDO, the employee record shows an address column(i.e. property):
@PersistenceCapable
public class Employee {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent(mappedBy = "employee")
private List<Address> addresses;
List<Address> getAddresses() {
return addresses;
}
void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}
// ...
}
@PersistenceCapable
public class Address {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private Employee employee;
@Persistent
private String Street;
...
}
The extra property is harmless. However why is this necessory for JDO?
I'm using GAE/J 1.7.2 with DataNucleus v2 on dev server.