| Summary: | EclipseLink doesn't escape column names, when it's a mysql keyword | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | G. Zsombor <zombi> |
| Component: | Eclipselink | Assignee: | Project Inbox <eclipselink.orm-inbox> |
| Status: | CLOSED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | be.ellenberger, edpeur, tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
This is not a bug. EclipseLink does not maintain a list of keywords for each platform. You should escape this attribute yourself when you map it. (in the @Column definition or the xml) As a preferred escaping method, use "\"KEY\"" in the @Column“s name if you wish to escape it. JPA 2.0 does provide support for using escaped names and this functionality is already present in EclipseLink 2.0 builds. Does that mean that I am supposed to escape every column name if I want my application to work with multiple databases? I would prefer that EclipseLink maintained the list of reserved words for each database. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 2.0.1 When an entity has a attribute 'key', EclipseLink can't load from MySQL, because it's fails to properly escape it, for example it generates the following query : SELECT VALUE, SITE, LANGUAGE, KEY FROM messages WHERE (((SITE = ?) AND (LANGUAGE = ?)) AND (KEY = ?)) However it should be something like this: SELECT VALUE, SITE, LANGUAGE, 'KEY' FROM messages WHERE (((SITE = ?) AND (LANGUAGE = ?)) AND ('KEY' = ?)) Reproducible: Always Steps to Reproduce: 1. Create an entity with attribute named 'key' 2. Try to store/load/query from MySQL 3. 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 'KEY .....