I have two entities, parent and child, that have a OneToMany relationship. The parent has an @Owned annotation for the child class. There is no relationship back. (from child to parent)
@Entity
public class Parent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Owned
@OneToMany(fetch = FetchType.LAZY)
private Set<Child> children;
.........
}
@Entity
public class Child {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
public String value;
.........
public int hashCode() {
... based on this.value ...
}
public boolean equals(Object o) {
... based on this.value ...
}
}
Question 1: Does this setup resemble an entity group where Parent is the ancestor? The following two statements do return an equal Key:
- child.getId().qv.getId().getParent()
- KeyFactory.createKey("Parent", parent.getId())
Question 2: Should the following code take about ten seconds to execute? It runs in about 223 milliseconds:
for(int i = 0; i < 10; i++) {
em.getTransaction().begin();
parent = em.find(Parent.class, parentId);
child = new Child("value" + i);
parent.addChild(child)
em.merge(parent)
em.getTransaction().commit();
}
The reason why I think it should take 10 seconds is because of this statement in the Google App Engine Documentation:
"However, the rate at which you can write to the same entity group is limited to 1 write to the entity group per second."
in https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore
Thanks