You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Pieper, Aaron (SAIC)" <Pi...@Pragmatics.com> on 2008/12/02 00:11:56 UTC

Referencing iterable fields as properties of a dynamic SQL statement

I'm having a problem using iBatis to implement a dynamic SQL query. For
this query, the user specifies a list of strings, and they're allowed to
specify "null". I want iBatis to query for the records matching the
strings they specify. If they specify "null" as one of the list
elements, then I want to include null records in my response.

My query worked OK until I tried to incorporate the null case. My SQL
map with the null case included looks something like this:

------------------------------------------------------------
SELECT *
FROM foo
WHERE
<iterate property="searchCriteria" conjunction=" OR ">
	<isNotNull property="searchCriteria[]">
		foo.bar=#searchCriteria[]#
	</isNotNull>
	<isNull property="searchCriteria[]">
		foo.bar is null
	</isNull>
</iterate>
------------------------------------------------------------

This produces a NumberFormatException, caused by "searchCriteria[]"
being specified as a property. If I change the property to
"searchCriteria" (without the braces) instead, then I don't get the
exception (but the resulting behavior is incorrect.)

This looks very close to the tracker IBATIS-42
(http://issues.apache.org/jira/browse/IBATIS-42) but that particular
tracker was marked as fixed in version 2.1.0, and I'm still seeing this
problem in 2.1.7.597. Should I submit a new tracker?

-	Aaron Pieper