I use hibernate\'s hbm2ddl to generate schema automatically. Here is my domain:
@Entity
public class Reader {
@Id
@GeneratedValue(strategy=GenerationTyp
Hibernate 5.2.x (Spring Boot 2.x) change default strategy for sequences, if DB supported one. So, with strategy=GenerationType.AUTO
, hibernate_sequence
is created, but id
is not autoincremented, based on this sequence, as must be:
create table users (id integer not null, ...)
instead of
create table table_name(id int default hibernate_sequence.nextval primary key, ...);
(see HHH-13268). There are several solutions:
@GeneratedValue
to strategy = GenerationType.IDENTITY
spring.jpa.properties.hibernate.id.new_generator_mappings=false
(spring-boot alias spring.jpa.hibernate.use-new-id-generator-mappings
)INSERT INTO TABLE(ID, ...) VALUES (hibernate_sequence.nextval, ...)
Try to use strategy=GenerationType.IDENTITY
instead of the strategy=GenerationType.AUTO
Also could be wrong hibernate.dialect Try the
hibernate.dialect=org.hibernate.dialect.H2Dialect