ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Rouillier <guyr-...@burntmail.com>
Subject Re: How to throw an exception when a property from a parameter map is null or missing?
Date Wed, 03 Feb 2010 16:49:07 GMT
On 2/3/2010 8:36 AM, Paul Spencer wrote:

> Ideally I would like to use a
> mode in the query parameter, like #{col2Value,nonNullValue=required},
> that would cause iBatis to throw an exception when the property
> evaluated to null.

If you are willing to impose a clause like that above, then just require 
something similar in a comment preceding the statement in the mapper 
file.  Then your generic engine can look for such comments and apply the 
constraints before invoking the query.  Something like this:

     <!-- @NotNull=col2Value, col3Value -->
     <select id="sampleQuery" parameterType="Map" resultType="Map">
         select column_1 from foo where column_2 = #{col2Value}
     </select>

-- 
Guy Rouillier

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


Mime
View raw message