[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-2178) When the sql statement submited to create the PreparedStatement contains comments, MySQL misunderstand it (and doubles the parameter count).

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Oct 25 11:19:05 EDT 2006


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2178?page=all ]
     
Steve Ebersole closed HHH-2178:
-------------------------------

    Resolution: Rejected

So then don't enable SQL comments with MySQL.  Or suggest how comments work in MySQL so that we can "fix it" if MySQL does really support 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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list