Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Collection and List of Strings

Received: by 10.229.247.203 with SMTP id md11mr206655qcb.4.1281715615550;
        Fri, 13 Aug 2010 09:06:55 -0700 (PDT)
X-BeenThere: mybatis-user@googlegroups.com
Received: by 10.229.173.155 with SMTP id p27ls1069642qcz.3.p; Fri, 13 Aug 2010
 09:06:54 -0700 (PDT)
Received: by 10.229.247.206 with SMTP id md14mr205799qcb.6.1281715614842;
        Fri, 13 Aug 2010 09:06:54 -0700 (PDT)
Received: by 10.229.247.206 with SMTP id md14mr205798qcb.6.1281715614797;
        Fri, 13 Aug 2010 09:06:54 -0700 (PDT)
Return-Path: <Christian.Poit...@ircm.qc.ca>
Received: from MGATE.ircm.qc.ca (mx1.ircm.qc.ca [207.162.51.9])
        by gmr-mx.google.com with ESMTP id y27si1634502qce.14.2010.08.13.09.06.54;
        Fri, 13 Aug 2010 09:06:54 -0700 (PDT)
Received-SPF: unknown (google.com: domain of Christian.Poit...@ircm.qc.ca uses a mechanism not recognized by this client. unknown  mechanisms: )) client-ip=207.162.51.9;
Authentication-Results: gmr-mx.google.com; spf=permerror (google.com: domain of Christian.Poit...@ircm.qc.ca uses a mechanism not recognized by this client. unknown  mechanisms: )) smtp.mail=Christian.Poit...@ircm.qc.ca
Received: from HERMES.ircm.priv ([172.16.9.26]) by hubcli1.ircm.priv
 ([172.16.9.31]) with mapi; Fri, 13 Aug 2010 12:06:51 -0400
From: Poitras Christian <Christian.Poit...@ircm.qc.ca>
To: "'mybatis-user@googlegroups.com'" <mybatis-user@googlegroups.com>
Date: Fri, 13 Aug 2010 12:06:51 -0400
Subject: RE: Collection and List of Strings
Thread-Topic: Collection and List of Strings
Thread-Index: Acs6/lyKN9hQQG3HQbOWSiAhUjkMMQAAmnBQ
Message-ID: <93B0CB1886D4CC48823246865D80DC9404F19D75B890@HERMES.ircm.priv>
References: <307ddc72-f683-46ee-a911-4b942f22a797@l14g2000yql.googlegroups.com>
 <AANLkTinVF67E9r7Zr=LhDQ8B+aVEisB6WfC-0oa7UCBd@mail.gmail.com>
 <609a8f45-8402-43c6-b690-daaed7606874@v41g2000yqv.googlegroups.com>
 <93B0CB1886D4CC48823246865D80DC9404F19D75B88D@HERMES.ircm.priv>
 <603c253a-c71c-4ed9-a974-8595af8c4fdc@z28g2000yqh.googlegroups.com>
 <93B0CB1886D4CC48823246865D80DC9404F19D75B88E@HERMES.ircm.priv>
 <0524d748-c5eb-41fa-b9eb-43c48a949...@c10g2000yqi.googlegroups.com>
In-Reply-To: <0524d748-c5eb-41fa-b9eb-43c48a949...@c10g2000yqi.googlegroups.com>
Accept-Language: fr-FR, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
acceptlanguage: fr-FR, en-US
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

For sure, if your SimpleDomain has some id field, you should use that field=
 for the <id> in your resultMap - not required but it is more logical.

Still, I am unsure about what MyBatis does in your case...

Christian

-----Original Message-----
From: mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] =
On Behalf Of q111111
Sent: Friday, August 13, 2010 11:44 AM
To: mybatis-user
Subject: Re: Collection and List of Strings

I changed to use <id property=3D"name" column=3D"NAME"/>.

I would like to say we made some progress ...
When I do this, the List contains one String and it is the same value as th=
e name it is pulling from the database.
Ex: name=3D"Bob", someStrings=3D{"Bob"}
I'm expecting to see someStrings=3D{"U","V","W","X","Y","Z"}

Just a thought ...
Do I need to add "id" (since part of Where clause) to my SimpleDomain and t=
hen use the <id> tag on it?
I didn't think so but I thought I would ask.

On Aug 13, 11:22=A0am, Poitras Christian <Christian.Poit...@ircm.qc.ca>
wrote:
> You can try to replace <result property=3D"name" column=3D"NAME"/> by <id=
 property=3D"name" column=3D"NAME"/>.
>
> I find that bizarre that you are getting null. It is as if MyBatis does n=
ot try to set the property at all...
>
> Christian
>
>
>
> -----Original Message-----
> From: mybatis-user@googlegroups.com=20
> [mailto:mybatis-user@googlegroups.com] On Behalf Of q111111
> Sent: Friday, August 13, 2010 11:17 AM
> To: mybatis-user
> Subject: Re: Collection and List of Strings
>
> Thank you for the suggestion.
>
> Still returning a null list.
>
> In case it matters, I am using myBatis 3.0.1 and Oracle 11g.
>
> Previously, I did successfully implement my mapper with two seperate sele=
ct statements ... one to fill name and one to fill someStrings from a secon=
d query.
> ex: <collection property=3D"someStrings" javaType=3D"list"
> column=3D"MYSTRING" ofType=3D"string" select=3D"MySuperQuery2"/>
>
> Now I am trying to get it down to a single SQL statement implementation.
> I'm keeping my fingers crossed.
>
> On Aug 13, 11:05=A0am, Poitras Christian <Christian.Poit...@ircm.qc.ca>
> wrote:
> > Try removing javaType from the <collection> section in your resultMap.
>
> > Personnaly, I don't use javaType with collection since javaType is usua=
lly guessed correctly by reflection.
> > Since your property is defined to be List, MyBatis will supply a valid =
implementation for you.
>
> > -----Original Message-----
> > From: mybatis-user@googlegroups.com
> > [mailto:mybatis-user@googlegroups.com] On Behalf Of q111111
> > Sent: Friday, August 13, 2010 10:54 AM
> > To: mybatis-user
> > Subject: Re: Collection and List of Strings
>
> > Thank you for the suggestion.
>
> > Still returning a null list.
>
> > Before the question is asked by someone else ...
> > Running the query straight in database returns 6 rows (Tbl1 has 1 row a=
nd Tbl2 has 6).
>
> > On Aug 13, 10:29=A0am, Simone Tripodi <simone.trip...@gmail.com> wrote:
> > > Hi!
> > > did you try with javaType=3D"java.util.ArrayList" instead of javaType=
=3D"list" ?
> > > let us know!
> > > Simo
>
> > >http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > > On Fri, Aug 13, 2010 at 3:37 PM, q111111 <q211222...@yahoo.com> wrote=
:
> > > > I am missing something but I am not sure what.
> > > > I want to fill a list of strings.
> > > > Currently, the SimpleDomain does return a name with a null list.
>
> > > > Java:
> > > > public class SimpleDomain
> > > > {
> > > > =A0 =A0String name;
> > > > =A0 =A0List<String> someStrings;
> > > > =A0 =A0//getters and setters here
> > > > }
>
> > > > Mapper:
> > > > <select id=3D"MySuperQuery" resultMap=3D"MyMap">
> > > > =A0 =A0 select tbl1.lname as NAME, tlb2.lstring as MYSTRING
> > > > =A0 =A0 =A0 =A0from tbl1
> > > > =A0 =A0 =A0 =A0left outer join tbl2 on tbl1.id =3D tbl2.id </select=
>
>
> > > > <resultMap id=3D"MyMap" type=3D"SimpleDomain">
> > > > =A0<result property=3D"name" column=3D"NAME"/>
> > > > =A0<collection property=3D"someStrings" javaType=3D"list" column=3D=
"MYSTRING"
> > > > ofType=3D"string"/>
> > > > </resultMap>
>
> > > > Thank you.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -