0
嗨我坚持一个类与接口的集合(列表)。需要关于使用jdo + datanucleus持久引用(嵌入)对象的确认
我看到这个链路 http://www.datanucleus.org/products/accessplatform_2_1/jdo/orm/embedded.html#Collection 和它说“嵌入式元素不能有继承(这可能会在未来被允许)”
那么,如何保持这样的对象?
嗨我坚持一个类与接口的集合(列表)。需要关于使用jdo + datanucleus持久引用(嵌入)对象的确认
我看到这个链路 http://www.datanucleus.org/products/accessplatform_2_1/jdo/orm/embedded.html#Collection 和它说“嵌入式元素不能有继承(这可能会在未来被允许)”
那么,如何保持这样的对象?
几小时前我遇到了同样的问题,希望能帮助其他人以jdo/datanucleus开头。
正如在current docs中所述,保持接口集合的唯一方法是通过unidirectional join table。直接嵌入实现接口的对象是不可能的。
@PersistenceCapable
public class SomeClass {
@Join
@Extension(vendorName="datanucleus", key="implementation-classes", value="ImplementingClass")
private List<SomeInterface> myList;
// this list would be embedded
private List<SomeOtherClass> myOtherList;
// ...
}
@PersistenceCapable
public interface SomeInterface {
// ...
}
@PersistenceCapable
public class ImplementingClass implements SomeInterface {
// ...
}
@PersistenceCapable(embeddedOnly="true")
public class SomeOtherClass {
// ...
}