Column names in generated SQL should be surrounded by the backtick character
----------------------------------------------------------------------------
Key: HHH-2660
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2660
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: All 3.2 versions. All databases. I use MySQL.
Reporter: William L Baker
Column names in generated SQL statements should be surrounded by backtick character. This
is necessary for column names that conflict with reserved words or functions. It is
easily demonstrated by creating a table with a column name DIV and a column name GROUP.
Hibernate currently generates invalid sql statements for accessing this table.
"select DIV, GROUP from NEWTABLE" gives a syntax error. "select `DIV`,
`GROUP` from NEWTABLE works as expected. It is only necessary to change two lines of code
to fix this behavior.
diff good\src\org\hibernate\sql\Insert.java bad\src\org\hibernate\sql\Insert.java
91c91
< buf.append( "`" + iter.next() + "`"
);
---
buf.append( iter.next() );
diff good\src\org\hibernate\sql\Update.java bad\src\org\hibernate\sql\Update.java
143c143
< buf.append( "`" + e.getKey() + "`"
).append( '=' ).append( e.getValue() );
---
buf.append( e.getKey() ).append( '='
).append( e.getValue() );
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira