is it possible to inherit the sequence generator of a base class in an jpa2.0 entity? The aim of this is to have the id property of all entities in a common base class and each entity just have to define the name of its own sequence.
This is what i want: Base class:
public abstract class BaseClass {
@Id
@GeneratedValue( strategy = GenerationType.AUTO, generator = "mySeqGenerator")
Long id;
}
and an implementation
@Entity
@SequenceGenerator( name = "mySeqGenerator", sequenceName = "the_seq" )
public class MyEntity extends BaseClass {
[..]
}
I’m using hibernate and is revokes this by “HHH000138: Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring sub strategy in MyEntity”
All generators are global to the Persistence Unit despite way how they were defined (in annotations on class level, field level or in
orm.xml).Therefore, you don’t need to “inherit” or “share” anything – you can just use it.