Hi. When I create the following class hierarchy (AAA <- BBB <- CCC):
[code]
@Inheritance(strategy = InheritanceType.JOINED)
@Entity
public class AAA {
@Id
public long id;
@Basic
public String aaa;
}
-------------------------------
@Entity
@PrimaryKeyJoinColumn
public class BBB extends AAA {
@Basic
public String bbb;
}
-------------------------------
@Entity
@PrimaryKeyJoinColumn
public class CCC extends BBB {
@Basic
public String ccc;
}
[/code]
and use Java2DB, the generated schema looks like this:
[code]
CREATE TABLE AAA (ID NUMBER(19) NOT NULL, DTYPE VARCHAR2(31) NULL, AAA VARCHAR2(255) NULL, PRIMARY KEY (ID))
CREATE TABLE BBB (ID NUMBER(19) NOT NULL, BBB VARCHAR2(255) NULL, PRIMARY KEY (ID))
CREATE TABLE CCC (ID NUMBER(19) NOT NULL, CCC VARCHAR2(255) NULL, PRIMARY KEY (ID))
ALTER TABLE BBB ADD CONSTRAINT FK_BBB_ID FOREIGN KEY (ID) REFERENCES AAA (ID)
ALTER TABLE CCC ADD CONSTRAINT FK_CCC_ID FOREIGN KEY (ID) REFERENCES AAA (ID)
[/code]
The thing is that the foreign key for CCC is referencing table AAA, not BBB. In this way, the CCC object would not have a way to persist the String bbb field.
Is this a JPA limitation - that only one level of inheritance is possible, or TopLink, or maybe it's a problem with schema generation? Or am I doing stuff incorrectly?
Thanks.
[Message sent by forum member 'szczyp' (szczyp)]
http://forums.java.net/jive/thread.jspa?messageID=318324