I try to have 2 tables, as follows:
MISExercise (table)
ID NAME ...
2 a
MISInteractiveExercise(table)
ID NAME ...
1 b
They must have no same id. And they are inherited from the same base. My code is :
@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class MISExerciseBase {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Integer id;
...
}
@Entity
public class MISExercise extends MISExerciseBase{
...
}
@Entity
public class MISInteractiveExercise extends MISExerciseBase{
...
}
Unfortunately, I find that the table of MISExercise and the table of MISInteractiveExercise can have the same id. When I google it I find http://openjpa.208410.n2.nabble.com/same-Id-on-mapped-superclass-td2435374.html. @Kaayan seems has the same problem. But I can't get help from that page.
And it seems if I use @Entity not @MappedSuperclass, it will be fine. But why, and what's the good way?