I came across an outdated system written to work with MySQL 5.0, and now I need to port it to MysQL 5.5 (requirement). I found that one column was named maxvalue , which seems to be the system word in MySQL 5.5. Thus, all my Hibernate queries that include this column give a syntax error:
Reason: java.sql.BatchUpdateException: you have an error in your SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use near 'maxvalue
Hibernate doesn't seem to do it automatically, but rather quotes `around the field name. If I retrieve the query, in `maxvalue` it works correctly in MySQL 5.5.
I found a solution on how to explicitly use backquotes for a specific field / table. The thing is, I'm not sure how many other column names will create such a problem. Is there a way to force Hibernate to automatically quote all table / column names? (which will produce valid SQL, and I do not know why it does not do this by default for MySQL).
EDIT : This discussion almost makes me believe that what I want is impossible.
java mysql escaping hibernate
Boris Strandjev Feb 18 '13 at 8:29 2013-02-18 08:29
source share