which produces me a 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 'starting, type, _id_usr_to, _id_usr_from FROM task WHERE (starting BETWEEN '2009'
Apparently a following query is being sent to MySQL:
Which MySQL rejects.
I changed the query manually to include the table qualifier and tested it directly on MySQL:
...and MySQL likes it. Now please help me get JPA to automatically use the table qualifier in the generated MySQL query.
Any help would be greatly appreciated.
Joined: Oct 29, 2009
I found out that starting is a reserved MySQL keyword, hence the MySQL syntax error.
Joined: Oct 01, 2007
Database reserved words need to be quoted if used. i.e. in your @Column set the name to "\"starting\"".
In JPA 2.0 you can also set all columns to be delimited in the orm.xml, using the <delimited-identifiers> element under <persistence-unit-defaults>.
Thanks for the suggestions.
Since I want to generate entity beans automatically in netbeans, I decided to just rename the column. Using quotes looks more like a hack to me and might cause some problems in the future.