[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2178?page=c...
]
Milosz Tylenda commented on HHH-2178:
-------------------------------------
The issue with comments occurs only when prepared statements are emulated by driver (so
called client-side statements). Recent versions of MySQL use server-side prepared
statements and don't suffer from this problem. I checked MySQL 5.0.24a with
Connector/J 3.1.14 and 5.0.3 and found no errors related to comments.
When the sql statement submited to create the PreparedStatement
contains comments, MySQL misunderstand it (and doubles the parameter count).
--------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2178
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2178
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: MySQL 3.2.0
Reporter: Diogenes Gomes
Priority: Trivial
When I used the following Hibernate properties:
hibernate.format_sql=true
hibernate.use_sql_comments=true
I found a bug in QueryLoader.java in method prepareQueryStatement:
...
sql = preprocessSQL( sql, queryParameters, dialect );
PreparedStatement st = null;
if (callable) {
st = session.getBatcher()
.prepareCallableQueryStatement( sql, scroll || useScrollableResultSetToSkip,
scrollMode );
}
else {
st = session.getBatcher()
.prepareQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
}
...
Before running preprocessSQL, the value of the local variable 'sql' was:
"select ... from ... where formulario0_.ffw_nome=?"
After running preprocessSQL, the value of 'sql' was: "/* from ... where
form.nome = ? */ select ... from ... where formulario0_.ffw_nome=?"
The value of st.parameterCount after running
session.getBatcher().prepareQueryStatement(...) was 2 (may be because of the double ? in
the sql statement). And I got a SQLException: "No value specified for parameter
2".
When I set both variables to false, it runs ok. The st.parameterCount is 1 and no
exception.
--
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