|"Generate Table from Entities" and reserved words [message #667897]
||Mon, 02 May 2011 16:22
| Roberto Viti
Registered: May 2011
Hello to everyone!|
I've just start to develop in Java EE 6 with "Eclipse Helios for web dev".
I've create my entities but when I trying to use the "Generate Table from Entities" tool, an error is popping out.
EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: 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 'Call (ID BIGINT NOT NULL, EXPIRIES DATE, NAME VARCHAR(255), PRIMARY KEY (ID))' at line 1
Error Code: 1064
Since MySQL 5.0, like they say here, "Call" is become a reserved word. Looking to the console output, the SQL statement that was passed to the DB is
CREATE TABLE CALL (ID BIGINT NOT NULL, EXPIRIES DATE, NAME VARCHAR(255), PRIMARY KEY (ID))
So the problem was there, but IMHO all the code got some problem. To comply MySQL's syntax recommendation, the code needs to be quite similar like this one
CREATE TABLE `RBDraft`.`CALL` (
`id` BIGINT NOT NULL,
`epiries` DATE ,
`name` VARCHAR(255) ,
PRIMARY KEY (`id`)
And that one, passed to mysql, create a table named "Call" like i want.
I've try to force the small caps naming for the table by using the "@Table (name= "Call")" annotation in the entity code, but nothing is changed.
There's a way to force the correct syntax when I using the tool or it's easiest to change the entity name? Is it my fault or a bug?
[Am I asking in the right place?]
Thank you all, and sorry for my bad english.
Powered by FUDForum
. Page generated in 0.02947 seconds