postgresql - GeneratedValue not recognizing existing hibernate_sequence -


i have user class

@entity public class user {      @id     @generatedvalue(strategy=generationtype.sequence)     @column(name = "id", updatable = false, nullable = false)     private long id; } 

and logs when running application

org.hibernate.tool.hbm2ddl.schemaexport  : hhh000227: running hbm2ddl schema export org.hibernate.tool.hbm2ddl.schemaexport  : hhh000389: unsuccessful: drop table if exists user cascade org.hibernate.tool.hbm2ddl.schemaexport  : error: syntax error @ or near "user" org.hibernate.tool.hbm2ddl.schemaexport  : hhh000389: unsuccessful: drop sequence hibernate_sequence org.hibernate.tool.hbm2ddl.schemaexport  : error: sequence "hibernate_sequence" not exist org.hibernate.tool.hbm2ddl.schemaexport  : hhh000389: unsuccessful: create table user (id int8 not null, primary key (id)) org.hibernate.tool.hbm2ddl.schemaexport  : error: syntax error @ or near "user" 

and here application.properties

spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.database=postgresql spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.postgresqldialect spring.datasource.driver-class-name=org.postgresql.driver 

my understanding on logs looking hibernate_sequence continue create user table.

i tried looking database used , hibernate_sequence automatically created - hence, error should not produced.

edit 1

i tried not use sequence , use generationtype.identity strategy instead still unable create table user.

edit 2

this whole build.gradle if version might issue on too.

buildscript {     ext {         springbootversion = '1.5.6.release'     }     repositories {         mavencentral()     }     dependencies {         classpath("org.springframework.boot:spring-boot-gradle-plugin:${springbootversion}")     } }  apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot'  version = '0.0.1-snapshot' sourcecompatibility = 1.8  repositories {     mavencentral() }   dependencies {     compile('org.springframework.boot:spring-boot-starter')     compile('org.springframework.boot:spring-boot-starter-web')      compile('org.projectlombok:lombok')     compile('org.springframework.boot:spring-boot-starter-data-jpa')     compile('org.springframework.boot:spring-boot-starter-security')      compile('org.postgresql:postgresql:9.3-1101-jdbc4')      testcompile('org.springframework.boot:spring-boot-starter-test') } 

to use sequence strategy generating id it's necessary define sequence generator first. example:

@entity @sequencegenerator(name="my_seq", initialvalue=1, allocationsize=100) public class user {      @id     @generatedvalue(strategy=generationtype.sequence, generator="my_seq")     private long id;      //... }  

more info here.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -