[英]Google App Engine HR Datastore - Java - Delete Entities programatically
[英]Cascade delete in Google app engine datastore
我在Google App Engine中有休閑類
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
public class A {
@PrimaryKey
@Persistent
String pk;
@Persistent(dependent = "true")
private B b;
.
.
.
}
和
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
public class B {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
.
.
.
}
我有一個創建對象的代碼:
{
PersistenceManager pm = PMF.get().getPersistenceManager();
A a = new A("pk1");
a.setB(new B(...));
try {
pm.makePersistent(a);
} finally {
pm.close();
}
}
之后,相同的代碼更新對象,並使用與A的主鍵相同的String。
{
PersistenceManager pm = PMF.get().getPersistenceManager();
A a = new A("pk1");
a.setB(new B(...));
try {
pm.makePersistent(a);
} finally {
pm.close();
}
}
由於我使用了'@Persistent(dependent =“ true”)',因此我期望在數據存儲區中最終得到一個A對象和一個B對象,但是我發現一個A對象和B對象作為這段代碼的時間跑。
我哪里錯了? 謝謝,以利
您期望GAE的數據存儲區是一個關系數據庫是錯誤的。 這是一個鍵值存儲,沒有級聯刪除的概念。
讓我建議您閱讀以下內容: http : //en.wikipedia.org/wiki/Nosql
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.