【发布时间】:2013-03-09 17:23:07
【问题描述】:
我的域对象看起来像这样:
@PersistenceCapable(detachable="true")
public class UserData implements java.io.Serializable
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
@NotNull
private String openId;
public UserData(String openId)
{
this.openId = openId;
}
}
现在我创建一个 UserData 对象并使用 JDO 使其持久化:
UserData userData = ThreadLocalPMF.getPersistenceManager().makePersistent(new UserData(openId));
稍后在代码中,我使用相同的 PersistenceManager、相同的线程在同一个仍处于打开状态的事务中进行查询:
Query query = ThreadLocalPMF.getPersistenceManager().newQuery(UserData.class, "openId == :openId");
query.setUnique(true);
UserData userData = (UserData)query.execute(openId);
现在发生了一次查询确实返回了 null 而不是之前在几行代码中持久化的对象。这里有什么问题?这是一个一致性问题吗?该应用正在使用 High Replication Datastore 与
<property name="datanucleus.appengine.datastoreEnableXGTransactions" value="true"/>
【问题讨论】:
标签: google-app-engine transactions persistence jdo