"Generate Table from Entities" and reserved words [message #667897] |
Mon, 02 May 2011 12:22  |
Eclipse User |
|
|
|
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.
|
|
|
|
|
Re: "Generate Table from Entities" and reserved words [message #668060 is a reply to message #667897] |
Tue, 03 May 2011 10:57  |
Eclipse User |
|
|
|
Roberto Viti wrote on Mon, 02 May 2011 12:22 |
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?
|
Dali delegates to your JPA runtime implementation, in this case EclipseLink, for the generation of tables from entities. So this is an EclipseLink bug most likely. I'm not sure of a workaround for the erroneous DDL generation; but you will need to use Neil's suggestion to get Dali to work once you do have the "Call" table built.
Also, you should be able to use MySQL standard backticks:
@Table (name= "`Call`")
instead of double-quotes if necessary. Double quotes will only work on MySQL if the ANSI_QUOTES SQL mode is enabled [1].
Brian
[1] http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
|
|
|
Powered by
FUDForum. Page generated in 0.04913 seconds