java - Id generation issue with Hibernate, liquibase and hsqldb -


i've created table using liquibase:

<createtable tablename="employees">     <column name="id" type="bigint">         <constraints primarykey="true" nullable="false"/>     </column>     <column name="name" type="varchar(50)">         <constraints nullable="false"/>     </column> </createtable> 

the following sql ddl query generated:

create table employees (id bigint not null, name varchar(50) not null, constraint pk_employees primary key (id)); 

the corresponding entity:

@entity @table(name="employees") public class employeeaccessproperty ...     @id     @generatedvalue     public long getid() {         return id;     } ... 

now, when try save via jpa implementation, sql query generated insert data:

hibernate: insert employees (id, name) values (default, ?) 2013-05-20t14:29:22.525+0700  warn  sql error: -5544, sqlstate: 42544 2013-05-20t14:29:22.526+0700  error  default keyword cannot used column has no default 

i expected, when don't specify id generation strategy, hibernate choose best 1 according provider. don't understand why id generation default value tried used. i'm not sure, side responsible error: hibernate, liqubase or hsqldb.

what can resolve problem? please me.

you not telling database primary key must autogenerated. create table way :

create table employees (id bigint generated default identity, name varchar(50) not null, constraint pk_employees primary key (id)); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -