ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DavidCAIT <dzaze...@cait.org>
Subject IsEmpty inside Iterate Tag
Date Wed, 08 Jul 2009 19:14:40 GMT


I am having trouble determining the correct syntax to use with the isEmpty
tag when iterating over a list. My program has a large list of objects with
potentially null fields and I need to customize my insert statements based
on whether or not a particular object has a certain field set to null. 

Here is my SqlMap file:

    <insert id="createObject" parameterClass="java.util.List">
        Insert into someTable (field1, field2, field3)
        Values <iterate conjunction=", ">
        (#[].field1#, <isNotEmpty property="[].field2">#[].field2#,
</isNotEmpty><isEmpty property="[].field2">NULL, </isEmpty> #[].field3#)

When I call this sqlMap, the isNotEmpty tag throws the following exception:

SqlMapClient operation; uncategorized SQLException for SQL []; SQL state
[null]; error code [0];
--- The error occurred in org/someFile/mySQL.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the Mapping.
--- Check the createObject parameter map.
Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal list
from JavaBean. Cause java.lang.StringIndexOutOfBoundsException: String index
out of range: -1; nested exception is
java.lang.StringIndexOutOfBoundsException: String index out of range: -1

What syntax should I use in the isNotEmpty property field to avoid this
exception? When I remove the isNotEmpty and isEmpty tags, the sql statement
executes successfully. I tried using property="#[].field2#" and
property="field2" but neither of those statements fixed the problem.

View this message in context: http://www.nabble.com/IsEmpty-inside-Iterate-Tag-tp24397605p24397605.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message