These are chat archives for hibernate/hibernate-orm

Dec 2016
Charis Anargyrou
Dec 02 2016 16:40

Hello all.
I would like to abstract common entity properties to a base class and each entity should extend this base class.
I am using the following code for the base class.

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class BaseType implements Serializable {

    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", updatable = false, nullable = false)
    private Long id;

    public Long getId() {
        return id;

    public void setId(Long id) { = id;


Everything works ok but I am having trouble the auto generated id. It look like the id is a sequence shared by all entities, i.e. if I have two entities extending the base one, say User and Role, then inserting a record in user table gives id = 1 and then inserting a record in role table gives id = 2.
How do I tell hibernate to use different sequence per entity? I thought GenerationType.TABLE should provide a sequence per table.