[英]Cascade delete in Google app engine datastore
I'm having the fallowing classes in Google app engine 我在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;
.
.
.
}
and 和
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;
.
.
.
}
I have a code that create the objects: 我有一个创建对象的代码:
{
PersistenceManager pm = PMF.get().getPersistenceManager();
A a = new A("pk1");
a.setB(new B(...));
try {
pm.makePersistent(a);
} finally {
pm.close();
}
}
and later the same code update the objects, with the same String as the primary key for A. 之后,相同的代码更新对象,并使用与A的主键相同的String。
{
PersistenceManager pm = PMF.get().getPersistenceManager();
A a = new A("pk1");
a.setB(new B(...));
try {
pm.makePersistent(a);
} finally {
pm.close();
}
}
Since I used the '@Persistent(dependent = "true")' I was expecting to ends up with one A object and one B object in the datastore, but I find one A object and B objects as the number of time that this code run. 由于我使用了'@Persistent(dependent =“ true”)',因此我期望在数据存储区中最终得到一个A对象和一个B对象,但是我发现一个A对象和B对象作为这段代码的时间跑。
Where am I wrong? 我哪里错了? Thanks, Eli 谢谢,以利
You are wrong in expecting that GAE's datastore is a relational database. 您期望GAE的数据存储区是一个关系数据库是错误的。 It's a key-value store and there is no concept of a cascading delete. 这是一个键值存储,没有级联删除的概念。
Let me suggest reading up on: http://en.wikipedia.org/wiki/Nosql 让我建议您阅读以下内容: http : //en.wikipedia.org/wiki/Nosql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.