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 Okan Çetin <ok...@gmail.com> on 2006/09/13 22:22:16 UTC

"queryForList" problem

Hi all;

I want to get some data from database that using ibatis

The code:

Integer user_id=usr.getuser_id();
List list=sqlMapper.queryForList("getEventidFromAttendance",user_id);

And the xml file is:

..
<select id="getEventidFromAttendance" parameterClass="int" resultClass="
java.util.List">
    select event_id from PUBLIC.attendance
    where user_id = #user_id#
 </select>
..

The problem:
String sample=list.get(0).toString();
sample contains : []
but its value must be a integer, like 5,10...
But the value of list.size(), is correct.

Where is my fault?

Thanks.
Okan.
-- 
~
otomatik oluşturuldu:
http://ocetin.net/log
http://linux.beykent.edu.tr

Re: "queryForList" problem

Posted by Nathan Maves <na...@gmail.com>.
You need to specify your resultClass as string and then call queryForList

On 9/13/06, Okan Çetin <ok...@gmail.com> wrote:
> Hi all;
>
> I want to get some data from database that using ibatis
>
> The code:
>
> Integer user_id=usr.getuser_id ();
> List
> list=sqlMapper.queryForList("getEventidFromAttendance",user_id);
>
> And the xml file is:
>
> ..
> <select id="getEventidFromAttendance" parameterClass="int"
> resultClass="java.util.List">
>      select event_id from PUBLIC.attendance
>     where user_id = #user_id#
>   </select>
> ..
>
> The problem:
> String sample=list.get(0).toString();
> sample contains : []
> but its value must be a integer, like 5,10...
> But the value of list.size(), is correct.
>
> Where is my fault?
>
> Thanks.
> Okan.
> --
> ~
> otomatik oluşturuldu:
>  http://ocetin.net/log
> http://linux.beykent.edu.tr

Re: "queryForList" problem

Posted by Jeff Butler <je...@gmail.com>.
Set your resultClass to java.lang.Integer.  With your current setup, you are
asking iBATIS to return a List of Lists.

Jeff Butler


On 9/13/06, Okan Çetin <ok...@gmail.com> wrote:
>
> Hi all;
>
> I want to get some data from database that using ibatis
>
> The code:
>
> Integer user_id=usr.getuser_id ();
> List list=sqlMapper.queryForList("getEventidFromAttendance",user_id);
>
> And the xml file is:
>
> ..
> <select id="getEventidFromAttendance" parameterClass="int" resultClass="
> java.util.List">
>     select event_id from PUBLIC.attendance
>     where user_id = #user_id#
>  </select>
> ..
>
> The problem:
> String sample=list.get(0).toString();
> sample contains : []
> but its value must be a integer, like 5,10...
> But the value of list.size(), is correct.
>
> Where is my fault?
>
> Thanks.
> Okan.
> --
> ~
> otomatik oluşturuldu:
> http://ocetin.net/log
> http://linux.beykent.edu.tr
>

Re: "queryForList" problem

Posted by Larry Meadors <lm...@apache.org>.
Make it resultClass="java.lang.String" or resultClass="string" instead.

Larry


On 9/13/06, Okan Çetin <ok...@gmail.com> wrote:
> Hi all;
>
> I want to get some data from database that using ibatis
>
> The code:
>
> Integer user_id=usr.getuser_id ();
> List
> list=sqlMapper.queryForList("getEventidFromAttendance",user_id);
>
> And the xml file is:
>
> ..
> <select id="getEventidFromAttendance" parameterClass="int"
> resultClass="java.util.List">
>      select event_id from PUBLIC.attendance
>     where user_id = #user_id#
>   </select>
> ..
>
> The problem:
> String sample=list.get(0).toString();
> sample contains : []
> but its value must be a integer, like 5,10...
> But the value of list.size(), is correct.
>
> Where is my fault?
>
> Thanks.
> Okan.
> --
> ~
> otomatik oluşturuldu:
>  http://ocetin.net/log
> http://linux.beykent.edu.tr