0

我拥有两个对象之间的一对多关系:

@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 异常。是否可以通过孩子的钥匙加载一个组?

4

1 回答 1

0

也许如果您引用您的代码来检索 AccessInfo 对象以及您如何获得您使用的“密钥”?

于 2009-11-01T15:35:29.463 回答