[ 
http://issues.apache.org/jira/browse/IBATIS-203?page=comments#action_12360956 ] 

Sven Boden commented on IBATIS-203:
-----------------------------------

The problem is in class com.ibatis.sqlmap.engine.mapping.sql.SQLText in the 
method:

  public void setText(String text) {
    this.text = text.replace('\r', ' ').replace('\n', ' ');
    this.isWhiteSpace = text.trim().length() == 0;
  }

Removing the first line of the method would solve the problem.

However this is the same old "problem" again of using the SQL query how it is 
specified in the XML file or "pretty printing" it. Removing the first line 
would make the logging output a little less nice.

Another solution would be to use the query as is (including newlines), and only 
pretty printing the SQL statement when it's actually required for logging 
purposes (this would also be a little faster without logging on).

Regards,
Sven

> Sql comments inside sqlMap's select tag, throws exception
> ---------------------------------------------------------
>
>          Key: IBATIS-203
>          URL: http://issues.apache.org/jira/browse/IBATIS-203
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.1.5
>  Environment: WinXP
>     Reporter: Henrik Westman

>
> Using sql comments i.e. lines prepended with "--", causes an exception.
> Seems like ibatis, parses the CDATA content of the select tag, 
> into one long line without any newlines.
> ex.
> <select>
>       <![CDATA[
>                 select * from myTable
>                -- here is my comment
>                 where myCol = 5
>         ]]>           
> </select>
> gets parsed into
>                 select * from myTable -- here is my comment where myCol = 5
> which is now invalid sql.
> Not being able to comment is annoying 
> when you have very long SQL statements.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to