Consider the query
INSERT INTO order (id, key, value) VALUES (?, ?, ?);
There are MySQL syntax errors in the above query as order
and key
are keywords in MySQL. So the solution would be to add backticks in the query.
INSERT INTO `order` (id, `key`, value) VALUES (?, ?, ?);
Hibernate is dumb enough not to do this automatically. According to this answer by adding the following property to the hibernate configuration file solves the problem with the table name.
<property name="hibernate.globally_quoted_identifiers">true</property>
But this only adds backticks to the database name and the table name. Problem is still there with the column name.
How can I add backticks to all the column names?
- Hibernate version : 3.6.10.Final
- MySQL version : 5.7
- hibernate.dialect : org.hibernate.dialect.MySQL5Dialect
- JDK version : 1.8 (if that has to do with anything)