我有以下 @MappedSuperClass 和 @Entity :
@MappedSuperclass
public class SuperClass implements Serializable {....}
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@Table(name = "TABLE1")
public class Table1 extends SuperClass implements Serializable {...}
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@Table(name = "TABLE2")
public class Table2 extends SuperClass implements Serializable {...}
在数据库中,两个表都有相同的列,所以我的所有属性都在 SuperClass 中:
@Id
private String attr1;
@Id
private String attr2;
@Column(name="DATA")
private String data;
// getters and setters
但是当我尝试使用@entity(table1 或 table2)之一执行查询时,我得到一个 OpenJPA ERROR :
Error pre-processing class table1 with weblogic.deployment.PersistenceUnitInfoImpl$ClassPreProcessorImpl@205c54b'
<openjpa-1.1.0-r422266:657916 fatal user error>
org.apache.openjpa.util.MetaDataException: Type "class SuperClass" with application identity and no superclass does not declare an id class.
This type is not eligible for builtin identity, so it must declare an id class.
我不明白为什么在@Entity 类中找不到属性@Id。
如果有人有任何想法,请随时帮助我:)
问候,
Cytemax