I am trying to implement ElcipseLink JPA2.0 for inheritance in my project. Can't use annotation. only xml mappings.
Here is my code. public class DefaultEntity {
}
public class SpecialEntity extends DefaultEntity {
public String name;
public int age;
}
public class AnotherSplEntity extends DefaultEntity {
long ts;
String pkey;
}
public class MyPersistableEntity {
public DefaultEntity de;
public void setMyPersistableEntity(DefaultEntity de) {
// any subclass can be assigned here.
this.de = de
}
here is my ORM.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" version="2.3">
<persistence-unit-metadata>
<exclude-default-mappings />
</persistence-unit-metadata>
<entity class="MyPersistableEntity">
<attributes>
<one-to-one name="de">
<cascade>
<cascade-all />
</cascade>
</one-to-one>
</attributes>
</entity>
<mapped-superclass class="DefaultEntity">
<attributes>
<id name="id" attribute-type="long">
<generated-value strategy="SEQUENCE" />
</id>
</attributes>
</mapped-superclass>
<entity class="SpecialEntity" >
<attributes>
<id name="id" attribute-type="long">
<generated-value strategy="SEQUENCE" />
</id>
<basic name="name" attribute-type="String" />
<basic name="age" attribute-type="int" />
</attributes>
</entity>
</entity-mappings>
I keep getting " uses a non-entity [class DefaultEntity] as target entity in the relationship attribute [field de]"
how to make EclipseLink recognize the actual class assigned and use that mapping?
any ideas? foremost, can it be done using EcliseLink?
thanks Gopi