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

Luke R. Flesch commented on IBATIS-227:
---------------------------------------

I've just experienced the issue described above.  I know you previously closed 
this issue with the following comment: 

"I don't see any compelling reason why SQL Maps should arbitrarily insert 
whitespace that was
not intended.  The solution is to simply add a space between the tag and the 
SQL text...I
can't see that being a problem.  Wherever possible, iBATIS favors leaving the 
SQL as it is
typed."

The problem is that my IDE, WSAD, strips out leading and trailing whitespace 
from XML elements when you ask it to format your XML.  I doubt that mine is the 
only editor that does this or that no-one else uses the format function of 
their editor.  

I think it would be worthwhile to change the iBATIS code to insert one space if 
none exist between the 'and' and the start of the SQL clause for dynamic 
elements.  Alternatively, you could check for this condition and print out a 
more helpful error message.  

By the way, I think iBATIS is a great package and I appreciate all the work you 
guys have done on it.  

- Luke

> CLONE -Dynamic SQL from JavaBean property causes malformed SQL
> --------------------------------------------------------------
>
>          Key: IBATIS-227
>          URL: http://issues.apache.org/jira/browse/IBATIS-227
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Reporter: Luke R. Flesch
>     Assignee: Clinton Begin
>      Fix For: 2.0.8

>
>  If there is a 'staff' class (mapped via a typeAlias)
> with a property 'salutation' which is of type
> 'Salutation' (itself a JavaBean), then the following
> dynamic SQL fragment causes an exception to be thrown:
> <select id="searchForStaff" parameterClass="staff"
> resultMap="staffResult">
> select * from staff
> <dynamic prepend="where">
> <isNotNull prepend="and" property="lastName">last_name
> = #lastName#</isNotNull>
> <isNotNull prepend="and"
> property="salutation">salutation_id =
> #salutation.id#</isNotNull>
> </dynamic>
> </select>
> Note the access of the 'id' property of the Salutation
> JavaBean and the absence of whitespace between the
> 'isNotNull' tag and its text content (the examples in
> the tutorial and developer guide have whitespace,
> avoiding the problem).
> The exception is a SQLException stating that the SQL
> command is not properly ended. Inspection of the SQL
> shows that a space is omitted between the 'and' and the
> condition, i.e. '... andsalutation_id = ...'.
> This only occurs when it is a JavaBean property being
> accessed.

-- 
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