Hi I'm having the fallowing classes in 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.
{
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.
Where am I wrong? Thanks, Eli