因此,当我加载偶数对象时,我无法加载场地和艺术家对象。基本上,当我创建一个活动时,我会加载特定的艺术家和特定的场地,并将密钥保存在活动的艺术家密钥和场地密钥字段中。但是,当我加载时,它始终为空。我已经在我的场地和艺术家上尝试了注释“@Persistent(defaultFetchGroup = "true")" 和 "@Persistent(mappedBy = "venue") @Element(dependent = "true")",但艺术家/场地仍然没有运气当我加载一个事件时显示为空(键在那里)。当我尝试使用 defaultFetchGroup 时,它说如果它已经被持久化,我将无法加载父级,我猜这是有道理的。
public class Event {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private Key artistKey;
@Persistent
private Key venueKey;
private Artist artist;
private Venue venue;
//other fields
//getters and setters
}
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Venue {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
//other fields
//getters and setters
}
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Artist {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
//other fields
//getters and setters
}