JDO 枚举实现接口
我正在尝试创建一个 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 时。 您对我能做什么才能持久保存实现特定接口的枚举列表有什么建议吗?
I'm trying to create a JDO persisted class, that contains a List of enums, that implement a specific interface.
Here is the code:
public interface Column {
}
public enum ColumnType1 implements Column {
VALUE11, VALUE12
}
public enum ColumnType2 implements Column {
VALUE21, VALUE22
}
And this is the persisted class:
@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 ...
}
The problem is that I'm getting this error:
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)
when I'm trying to persist a ListTable.
Do you have any suggestions of what can I do to be able to persist a List of enumerations, that implement a specific interface?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
接口的“第二类对象”(SCO) 实现不是 JDO 可持久类型(请参阅 JDO 规范)。接口用于持久类型 (FCO)
"Second-Class Object" (SCO) implementation of an interface is not a JDO persistable type (see the JDO spec). Interfaces are for persistable types (FCOs)