You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Edvin Syse <ed...@sysedata.no> on 2009/12/01 09:42:48 UTC
IBATIS3: Is it possible to iterate over unnamed/single parameter?
I want to do a select where the parameter is a List<Integer>:
<select id="byEntities" resultType="Location" resultMap="Location" parameterType="List">
SELECT * FROM entity_location
WHERE entity IN <foreach item="item" index="index" collection="list" open="("
separator="," close=")"> #{item} </foreach>
</select>
I don't have a domain object to hold my list of ints, so I'm trying to supply just the
List<Integer> to the mapper method.
It seems that the collection="list" doesn't pick up the default parameter, like say #{ref}
would do. Is there a way to iterate over a non-named paramter, or do I need to wrap my
list in another object to make this work?
Sincerely,
Edvin Syse
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
AW: IBATIS3: Is it possible to iterate over unnamed/single
parameter?
Posted by Stephen Friedrich <st...@fortis-it.eu>.
IMHO it should work with "Integer...", too, if you change
collection="list"
to
collection="arary"
-----Ursprüngliche Nachricht-----
Von: Edvin Syse [mailto:edvin@sysedata.no]
Gesendet: Dienstag, 1. Dezember 2009 09:51
An: user-java@ibatis.apache.org
Betreff: Re: IBATIS3: Is it possible to iterate over unnamed/single parameter?
Oups, my mistake: It does work with Lists just as advertised in the user guide, but it
doesn't work with varargs, I had mistakenly sent in Integer... instead of List<Integer>.
-- Edvin
Edvin Syse skrev:
> I want to do a select where the parameter is a List<Integer>:
>
> <select id="byEntities" resultType="Location" resultMap="Location"
> parameterType="List">
> SELECT * FROM entity_location
> WHERE entity IN <foreach item="item" index="index"
> collection="list" open="(" separator="," close=")"> #{item} </foreach>
> </select>
>
> I don't have a domain object to hold my list of ints, so I'm trying to
> supply just the List<Integer> to the mapper method.
>
> It seems that the collection="list" doesn't pick up the default
> parameter, like say #{ref} would do. Is there a way to iterate over a
> non-named paramter, or do I need to wrap my list in another object to
> make this work?
>
> Sincerely,
> Edvin Syse
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: IBATIS3: Is it possible to iterate over unnamed/single parameter?
Posted by Edvin Syse <ed...@sysedata.no>.
Oups, my mistake: It does work with Lists just as advertised in the user guide, but it
doesn't work with varargs, I had mistakenly sent in Integer... instead of List<Integer>.
-- Edvin
Edvin Syse skrev:
> I want to do a select where the parameter is a List<Integer>:
>
> <select id="byEntities" resultType="Location" resultMap="Location"
> parameterType="List">
> SELECT * FROM entity_location
> WHERE entity IN <foreach item="item" index="index"
> collection="list" open="(" separator="," close=")"> #{item} </foreach>
> </select>
>
> I don't have a domain object to hold my list of ints, so I'm trying to
> supply just the List<Integer> to the mapper method.
>
> It seems that the collection="list" doesn't pick up the default
> parameter, like say #{ref} would do. Is there a way to iterate over a
> non-named paramter, or do I need to wrap my list in another object to
> make this work?
>
> Sincerely,
> Edvin Syse
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org