How to specify a different column for a @Inheritance JPA annotation
- by Cue
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Foo
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class BarFoo extends Foo
mysql> desc foo;
+---------------+-------------+
| Field | Type |
+---------------+-------------+
| id | int |
+---------------+-------------+
mysql> desc barfoo;
+---------------+-------------+
| Field | Type |
+---------------+-------------+
| id | int |
| foo_id | int |
| bar_id | int |
+---------------+-------------+
mysql> desc bar;
+---------------+-------------+
| Field | Type |
+---------------+-------------+
| id | int |
+---------------+-------------+
Is it possible to specify column barfo.foo_id as the joined column?
Are you allowed to specify barfoo.id as BarFoo's @Id since you are overriding the getter/seeter of class Foo?
I understand the schematics behind this relationship (or at least I think I do) and I'm ok with them.
The reason I want an explicit id field for BarFoo is exactly because I want to avoid using a joined key (foo _id, bar _id) when querying for BarFoo(s) or when used in a "stronger" constraint. (as Ruben put it)