com.something.SuperClass:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class SuperClass implements Seria
Agree with zoidbeck's answer. You need to change strategy to:
@GeneratedValue(strategy = GenerationType.TABLE)
But that's not all, you need to create a new table, what will hold your abstract's table primary key sequence. Modify your mapping to
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "ConfirmationCodeGenerator")
@TableGenerator(table = "SEQUENCES", name = "ConfirmationCodeGenerator")
public long getConfirmationCode() {
return confirmationCode;
}
And a new table in database should look like following:
When you ran your application, Hibernate will insert a row where sequence_name
will be the entity name (SuperClass
in this example) and sequence_next_hi_value
value will be automatically incremented and used for new records of all implementing subclasses's tables.