I have a problem where @GeneratedValue(strategy=GenerationType.AUTO)
is not working properly. I have the error saying that kcyn.hibernate_sequence
does not exist.
I read to following topic : hibernate could not get next sequence value. It says that I should change AUTO
by IDENTITY
. But then, I have an error saying that a NULL value is added into primary key.
If I am starting from an non existing table, with AUTO
strategy, hibernate auto-magically creates airroute
table with an hibernate_sequence
table.
But, since I want to work with an existing database, my question would be, which GenerationType
should I use in order to have my id automatically generated?
package models;
import javax.persistence.*;
@Entity
public class Airroute {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long id;
public String label;
public String spokenname;
public Boolean internal;
public String descr;
public String direction;
}
UPDATED
Maxsim=# \d+ "KCYN-GOLD-USMC_3_141_553".airroute
Table "KCYN-GOLD-USMC_3_141_553.airroute"
Column | Type | Modifiers | Storage | Stats target | Description
------------+----------------+-----------+----------+--------------+-------------
id | numeric(11,0) | not null | main | |
label | character(8) | | extended | |
spokenname | character(60) | | extended | |
internal | boolean | | plain | |
descr | character(250) | | extended | |
direction | character(1) | | extended | |
Indexes:
"airroute_pkey" PRIMARY KEY, btree (id)