Hello,
I am trying to generate IDs using GenerationType.TABLE and MySQL but encounters some problem.
Since it may matter I have defined the connection properties in my hibernate.cfg.xml file.
Here is my code:
Code:
@Id
@GeneratedValue(strategy=GenerationType.TABLE, generator="EMP_GEN")
@TableGenerator(name="EMP_GEN", table="GENERATOR_TABLE", pkColumnName = "key", valueColumnName = "hi", pkColumnValue="value", allocationSize=10)
public Long getOrderNumber(){
return orderNumber;
}
And my Error:
Code:
ERROR: could not read or init a hi value
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'value' for update' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
Does anyone know what the problem could be? And where can I get good references for how @TableGenerator works?
Thank you in advance!
Regards,
Niklas