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 lihh <ha...@gmail.com> on 2007/10/11 21:13:36 UTC

retrieve a list of strings, how?

Hi all,

I am very new on iBatis and I have searched this forum and followed few of
the examples but still not able to get this to work.

In my sqlmap I have this
<resultMap id="ClueEntry" class="ClueEntry">
   ...
   ...
   <result property="memberList" column="id" select="getMemberListById" />
</resultMap>

  <select id="getMemberListById" parameterClass="java.lang.String"
resultClass="java.lang.String">
  	SELECT fullname FROM members where members.specialid = #id#
  </select>

the id is a special id, multiple people can have the same id #, I verified
the statement on the sql server and I got a list of 4 names. However, the
result for memberList is always null.

the ClueEntry class is like this:
public ClueEntry {
...
...
   private List memberList = new ArrayList();
...
...
	public List getMemberList () {
		return this.memberList ;
	}

	public void setMemberList (List memberList ) {
		this.memberList = memberList ;
	}
...
...
}

The ClueEntry class also contains other simple primitive types like string
and integer and I can get the data  into the resultmap without a problem.

Can someone point out to me what have I done wrong here? Thank you very much
for your help.
-- 
View this message in context: http://www.nabble.com/retrieve-a-list-of-strings%2C-how--tf4609397.html#a13162784
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


RE: retrieve a list of strings, how?

Posted by lihh <ha...@gmail.com>.
Hi Niels,

Thank you very much for the reply. It was all my fault. I was following the
wrong variable when I was debugging the application.

I kept looking at the "resultObject" value in memberList when setMemberList
was called, this value was always null and I thought the result should get
stored there.

I added this to test the result and memberList did contains the result from
the database.
List list = entry.getMemberList();
String test = list.toString();

Thank you.


Niels Beekman-2 wrote:
> 
> Looks good to me, can you enable debugging and see if the statement
> actually executes? Also, post the select statement that uses the
> ClueEntry result map and the corresponding Java-code.
> 
> Niels
> 
> -----Original Message-----
> From: lihh [mailto:hanhuali@gmail.com] 
> Sent: donderdag 11 oktober 2007 21:14
> To: user-java@ibatis.apache.org
> Subject: retrieve a list of strings, how?
> 
> 
> Hi all,
> 
> I am very new on iBatis and I have searched this forum and followed few
> of
> the examples but still not able to get this to work.
> 
> In my sqlmap I have this
> <resultMap id="ClueEntry" class="ClueEntry">
>    ...
>    ...
>    <result property="memberList" column="id" select="getMemberListById"
> />
> </resultMap>
> 
>   <select id="getMemberListById" parameterClass="java.lang.String"
> resultClass="java.lang.String">
>   	SELECT fullname FROM members where members.specialid = #id#
>   </select>
> 
> the id is a special id, multiple people can have the same id #, I
> verified
> the statement on the sql server and I got a list of 4 names. However,
> the
> result for memberList is always null.
> 
> the ClueEntry class is like this:
> public ClueEntry {
> ...
> ...
>    private List memberList = new ArrayList();
> ...
> ...
> 	public List getMemberList () {
> 		return this.memberList ;
> 	}
> 
> 	public void setMemberList (List memberList ) {
> 		this.memberList = memberList ;
> 	}
> ...
> ...
> }
> 
> The ClueEntry class also contains other simple primitive types like
> string
> and integer and I can get the data  into the resultmap without a
> problem.
> 
> Can someone point out to me what have I done wrong here? Thank you very
> much
> for your help.
> -- 
> View this message in context:
> http://www.nabble.com/retrieve-a-list-of-strings%2C-how--tf4609397.html#
> a13162784
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/retrieve-a-list-of-strings%2C-how--tf4609397.html#a13177015
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.