我正在尝试创建一个JDO持久化类,它包含一个实现特定接口的枚举列表。代码如下:
public interface Column {
}
public enum ColumnType1 implements Column {
VALUE11, VALUE12
}
public enum ColumnType2 implements Column {
VALUE21, VALUE22
}这是持久化的类:
@PersistenceCapable(detachable = "true")
public class ListTable implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.UUIDHEX)
@Column(jdbcType = "VARCHAR", length = 32)
private String encodedKey;
// the list of columns that can be displayed in the table
@Persistent(defaultFetchGroup = "true", nullValue = NullValue.EXCEPTION)
private List<Column> columns;
// constructor and getters ...
}问题是我得到了这个错误:
javax.jdo.JDOUserException: The MetaData for the element class "com.example.shared.model.Column" of the collection field "com.example.shared.model.ListTable.columns" was not found.
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:497)
at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:671)
at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:691)当我试图持久化一个ListTable时。你有什么建议吗?我可以做些什么来持久化实现特定接口的枚举列表?
发布于 2011-11-08 03:02:10
接口的“第二类对象”(Second-Class Object,SCO)实现不是JDO持久类型(参见JDO规范)。接口用于持久化类型(FCO)
https://stackoverflow.com/questions/8040875
复制相似问题