ibatis problem using <isNull> whilst iterating over a List
Posted
by onoma
on Stack Overflow
See other posts from Stack Overflow
or by onoma
Published on 2010-04-26T17:02:30Z
Indexed on
2010/04/26
17:23 UTC
Read the original article
Hit count: 429
Hi,
I'm new to iBatis and I'm struggling with the and elements.
I want to iterate over a List of Book instances (say) that are passed in as a HashMap: MyParameters. The list will be called listOfBooks.
The clause of the overall SQL statement will therefore look like this:
<iterate prepend="AND" property="MyParameters.listOfBooks" conjunction="AND" open="(" close=")">
...
</iterate>
I also need to produce different SQL within the iterate elements depending on whether a property of each Book instance in the 'listOfBooks' List is null, or not.
So, I need a statement something like this:
<iterate prepend="AND" property="MyParameters.listOfBooks" conjunction="AND" open="(" close=")">
<isNull property="MyParameter.listOfBooks.title">
<!-- SQL clause #1 here -->
</isNull>
<isNotNull property="MyParameter.listOfBooks.title">
<!-- SQL clause #2 here -->
</isNotNull>
When I do this I get an error message stating that there is no "READABLE" property named 'title' in my Book class. However, each Book instance does contain a title property, so I'm confused! I can only assuem that I have managled the syntax in trying to pinpoint the title of particular Book instance in listOfBooks. I'm struggling to find the correct technique for trying to achieve this. If anyone can advise a way forward I'd be grateful.
Thanks
© Stack Overflow or respective owner