Hi,
Just registered because I have observed a weird problem (which presumably has something to do with my configuration).
Hibernate version:
3.2.5.ga
Mapping documents:
Simplets example:
Code:
<class name="FieldDescription" table="FieldDescriptions">
<property name="key" type="string" />
<property name="value" type="string" />
</class>
Code between sessionFactory.openSession() and session.close():Using the HibernateTemplate from Spring:
Code:
FieldDescription fd = new FieldDescription();
fd.setKey("example");
fd.setValue("Example Field");
getHibernateTemplate().merge(fd);
Name and version of the database you are using:MySQL 5.0.44 (Gentoo Linux patched) on a development laptop.
The generated SQL (show_sql=true):Code:
insert into FieldDescriptions (key, value) values (?, ?)
Hibernate is set to use the MySQL5InnoDBDialect, but the generated SQL does not escape the key column. The word key is reserved in MySQLs dialect, so a MySQL error is returned stating that there is a syntax-error near: "key, value) values (?, ?)"
Of course I have already worked around this by changing the name "key" to something else as that makes life easier for everyone, but I am still wondering if I've missed something in the configuration? Is there some setting to tell Hibernate to escape the column names?