Multiple parameter support like this:
insertSomething(@Param("param1") int param1, @Param("param2") int param2)

is basically shorthand for:
Map params = new HashMap();
params.put("param1", someObject);
params.put("param2", otherObject);


So, the parameter type for multiple parameters is always Map.

<insert ... parameterType="map">

Parameter type binding in iBATIS 3 is a lot looser than it was in iBATIS 2,
and is more like iBATIS 1.  There's not a lot of benefit to locking down the
parameter type, so I went with the simpler syntax to avoid something like
the Generics over-typing nightmare.

iBATIS knows the type of the parameter when you pass it.

Clinton

On Sun, Oct 11, 2009 at 11:50 PM, Guy Rouillier <guyr-...@burntmail.com>wrote:

> Clinton Begin wrote:
>
>>  List selectList(String statement, Object parameter, RowBounds rowBounds)
>>  void select(String statement, Object parameter, RowBounds rowBounds,
>> ResultHandler handler)
>>
>> These methods used to take two int params to define the OFFSET and LIMIT
>> for limiting the rows that were returned (for paging etc)  We've introduced
>> the RowBounds class to clean that up, but also to allow for multi-parameter
>> bindings.  So that this is now possible in Mapper classes:
>>
>>  List<Post> findAllPostsLike(@Param("subject") String subject,
>> @Param("body") String body, RowBounds rowBounds);
>>
>> RowBounds can be any parameter, not necessarily the last one.  You don't
>> have to specify @Param, as it will default to using the ordinal position
>> e.g. #{1} #{2}, but with the @Param annotations, you can use #{subject} and
>> #{body}.  If you only specify a single parameter, then it's passed as
>> always, as the top level parameter (with all properties accessible by name
>> without qualification).
>>
>
> Clinton, thank you very much for the tremendous amount of effort you put
> into iBatis.
>
> I'm unclear about the XML implementation of multiple parameter bindings.  I
> couldn't find any full examples in the PDF, so I looked in
> XMLStatementBuilder.java.  Looks like parameterType is still a single-valued
> entry.  So, with the example you provide above, what would we enter for
> parameterType in the XML file?  Seems like parameterType will have to become
> a multi-valued list (comma-separated or some alternative.)
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
> For additional commands, e-mail: user-java-h...@ibatis.apache.org
>
>

Reply via email to