我有兩個實體,parent
和child
,其中有OneToMany relationship
。父級有子類的@Owned
註釋。沒有關係。 (從子到父)實體組,JPA和每秒一次寫入限制(應用程序引擎)
@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 ...
}
}
問題1:此安裝類似,其中家長是祖先的實體組?下面的兩個語句做回一個平等的關鍵:
- child.getId().qv.getId().getParent()
- KeyFactory.createKey("Parent", parent.getId())
問題2:如果下面的代碼要花10秒鐘來執行?它運行在大約223毫秒:
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();
}
爲什麼我覺得應該需要10秒的原因是因爲這種說法在谷歌App Engine文檔的:
「然而,速率您可以寫入相同的實體組,限制爲每秒寫入實體組。「
在https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore
感謝
謝謝你的回答。 因爲這個原因需要10秒鐘: 「但是,您可以寫入同一個實體組的速率限制爲每秒寫入實體組1次。」 在https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore – nanotvi 2013-04-04 15:04:03