Hi,
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#)
</iterate>
</insert>
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
com.ibatis.common.jdbc.exception.NestedSQLException:
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.
Thanks!
--
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: [email protected]
For additional commands, e-mail: [email protected]