I am trying to implement a very simple inheritance model in Hibernate. Basically, I have one superclass, which can be called A , and several subclasses, all of which inherit from A Since the behavior that I see is the same for all of them, they can simply be called B
I am trying to find what is described here in section 6.2. Basically, there should be a table for A that contains its fields, and a table for B that contains only fields that are different from the subclass, plus a join column back to the table for A I use Hibernate auto-build circuitry (enabled only for stability unit).
However, when I look at the diagram, this table for A contains its fields (correctly) and the table for B , which contains all the fields in A (incorrect), plus the fields added to B My classes are annotated as follows:
@Entity @Table(name="A") @Inheritance(strategy = InheritanceType.JOINED) public class A implements Serializable { protected long id; protected Date createDate; protected String title; protected boolean hidden; public A() { } @Id @GeneratedValue(strategy = GenerationType.AUTO) public long getId() { return id; } @Column(nullable = false) @Temporal(TemporalType.TIMESTAMP) public Date getCreateDate() { return createDate; } @Column(nullable = false) public boolean isHidden() { return hidden; } @Column(nullable = false) public String getTitle() { return title; }
Any ideas what I did wrong? In particular, what I want to see when I look at the generated database schema looks something like this:
Table A: {id, createDate, title, hidden} Table B: {aId, extraField}
... and instead I get:
Table A: {id, createDate, title, hidden} Table B: {id, createDate, title, hidden, extraField}
Is this simply not possible using the Hibernate automatic schema scheme, or did I screw annotations somewhere?