Reputation: 660
I'm having some trouble creating tables using Hibernate with the following exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect column specifier for column 'id'
Unable to execute schema management to JDBC target [create table services (id varchar(255) not null auto_increment, adult_cost double precision not null, child_cost double precision not null, partner_id varchar(255) not null, primary key (id)) ENGINE=InnoDB]
My code for the ID column is as follows:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
From what I understand, this exception normally occurs when you try to assign an auto_increment to a non-numeric but as you can see - I've defined id as an int.
Any help appreciated.
Upvotes: 1
Views: 8632
Reputation: 157
When you select primary key or any key select and give apply/go then check whether its auto incremented with not null specification then its defenitly works
Upvotes: 1
Reputation: 54672
use GenerationType.IDENTITY
instead of GenerationType.AUTO
. Mysql doesn't use table to generate id values.
Upvotes: 0