I don't think this is possible. If you have inheritance, i believe the primary key class/field needs to be the same for all subclasses. I'll double check with the EG.
It works when using TABLE_PER_CLASS or SINGLE_TABLE strategies.
In my case, this is ennoying because A should be abstract. Therefore I don't need to have a table in the database for that class.
Is is possible to declare the inheritance in Hibernate and specify not to create a table for class A ?
Don't mark the abstract class as an @Entity.
ONE MORE THING....
Keep these kind of use cases coming...I'm am forwarding your input to the EG as its good stuff.
Not marking the abstract class as @Entity only works if there is no relationship with other classes.
One of the reason I wanted to use an abstract class is that their should be a ManyToOne relationship with this class.
When I don't specify it as @Entity, I get a "normal" MappingError.
What I'd like to do is:
A is an abstract class, with no table in the DB
B and C inherits from A
D has many instances of A.
Checked with EG. I was correct. You are not allowed to do this as per the spec. In an inheritance mapping, all primary keys must be the same types and defined int he base class.