我拥有两个对象之间的一对多关系:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class AccessInfo {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private com.google.appengine.api.datastore.Key keyInternal;
...
@Persistent
private PollInfo currentState;
public AccessInfo(){}
public AccessInfo(String key, String voter, PollInfo currentState) {
this.voter = voter;
this.currentState = currentState;
setKey(key); // this key is unique in whole systme
}
public void setKey(String key) {
this.keyInternal = KeyFactory.createKey(
AccessInfo.class.getSimpleName(),
key);
}
public String getKey() {
return this.keyInternal.getName();
}
以及
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PollInfo
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent(mappedBy = "currentState")
private List<AccessInfo> accesses;
...
我创建了一个类pollinfo的示例并使其持久化。没关系。但是我想通过accessinfo键加载这个组,得到异常nucleusobjectnotfoundexception。是否可以按孩子的键加载组?
1条答案
按热度按时间rqenqsqc1#
如果您引用检索accessinfo对象的代码,以及如何获得所使用的“密钥”?