Does each table have its own id field? This is where the join occurs.
I have three classes that participate in inheritance in my JOIN example, and you will notice that each has its own id field:
I have a little tutorial on mapping inheritance that you might find interesting. A Joined table mapping is provided as an example:
The Three Forms of Inheritance Mapping with Hibernate: A Simple Tutorial
Joined Table Inheritance
One of the ugly aspects of the TABLE_PER_CLASS inheritance type is the fact that properties get duplicated down the class hierarchy. For example, why should the child table declare columns of type id and nationality when they are already defined in the ancestor table? The JOINED inheritance type addresses this problem by having tables only maintain data that maps directly to the properties in the associated class. Subclasses are then linked to their inherited properties through common primary key fields in the tables, linking as UNION joins at runtime.
To use a JOIN for mapping inheritance, all we have to do is edit the @Inheritance annotation of the Ancestor class, and set the strategy attribute to InheritanceType.JOINED:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Ancestor { ... }
When using a JOINED strategy for our problem domain, Hibernate expects three database tables, with each table mapping to the various properties defined in each class. The id field then forms a union between tables. So, if an Ancestor instance is saved, a record will be created in only the ancestor table, whereas if a Child instance is created, the fields of the instance will be saved in all three tables, with the records in each table associated, or joined, through a common value for the id field. In essence, the class hierarchy of an instance is JOINED together from all of the individual tables.
Goodl luck!
-Cameron McKenzie