Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set H2 primary key id to auto_increment?

i am using sql, H2, and i am trying to make so that the ID of Usertable is auto_incremented. i tried all sql commands in H2 sql interface, didnot work out.

alter table user alter column int not null auto_increment;

this common one is even not working. is there any annotation of JPA for auto_incement may be?

thanks a lot

like image 909
doniyor Avatar asked Jul 02 '12 19:07

doniyor


1 Answers

You should use the JPA annotations @Id and @GeneratedValue for your ID.

Your SQL looks valid. Can you post the error message?

like image 164
Leonard Punt Avatar answered Oct 04 '22 20:10

Leonard Punt