Issue
I have a class that is a table within a postgress database. The class is then extended by the other classes. The main class has the following annotation at the top
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@Entity
@Table(name="policy_action")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class PolicyAction {
@Id
@GeneratedValue(strategy=GenerationType.TABLE)
@Column(name="id")
private int id;
.....
the second class
public class myspecialPolicy extends policy {
....
}
when inserting into the database the following error is thrown
org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist
I am not sure how to solve this problem any help will be grateful thanks in advance.
Solution
What solved my problem was creating a hibernate_sequence table with nxt_val column with a long datatype in my database.
Sql
Create hibernate_sequence(nxt_val long);
and then
Insert into hibernate_sequence (nxt_val) values ('12')
NB the value 12 can be any number.
Now what happens is, hibernate will pick the value in the nxt_val to determine the sequence generation with specifying anything. It works for well for TableGenerator, Sequence, Auto
Answered By - Johnyoat