I am using datanucleus JDO API for persisting objects. my orm file looks like this:
<class name="MyClass" table="mytable">
<inheritance strategy="complete-table"/>
<field name="id" column="id" primary-key="true" value- strategy="AUTO_INCREMENT"/>
</class>
I have an inheritance hierarchy of
@PersistenceCapable
public class MyClass extends NonAbstractMyClassParent {
}
public class NonAbstractMyClassParent extends AbstractMyClassParent
{
}
public class AbstractMyClassParent
{
private Long id;
}
The id is defined in the MyClassAbstractParent. MyClassParent does NOT have a corresponding table in the database.
When I try to persist the MyClass, I get the below error. I tried making the MyClassParent also abstract but still I get the same error. Any insights please? TIA
javax.jdo.JDOException: Metadata for member "com.xxx.MyClass.id" is attempting to illegally override the primary-key setting of its "root" metadata definition (annotations or ".jdo" XML file). You must specify primary-key information in the "root" metadata definition
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.initialiseMetaData(JDOPersistenceManagerFactory.java:772)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.(JDOPersistenceManagerFactory.java:564)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:308)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:217)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1975)