I've got a query that does a call to select a list: getSqlSessionTemplate().selectList(query, params);
When I run the query directly against mysql, I get 2 rows returned. When Mybatis 3.1.1 runs it, it only returns 1 object in the list.
Here are some details, with some of the names changed to protect the innocent. If I happened to make a typo doing the changes, that's probably not the source of this problem:
CREATE TABLE `sanity_tests` (
`sanity_id` int(12) unsigned NOT NULL,
`sanitycode` char(3) NOT NULL DEFAULT '',
`sid` int(12) unsigned NOT NULL DEFAULT '0',
`rid` int(12) unsigned NOT NULL DEFAULT '0',
`rcode` varchar(2) NOT NULL DEFAULT '',
`cid` int(12) unsigned NOT NULL DEFAULT '0',
`gid` varchar(4) NOT NULL DEFAULT '',
PRIMARY KEY (`sanity_id`,`sanitycode`,`ctid`,`rid`,`cid`,`gid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Here's the query:
<select fetchSize="100" resultSetType="FORWARD_ONLY" id="getSanityDest" resultMap="sanityDest">
select sanity_id,sanitycode,sid ,rid,rcode,cid,gid from sanity_tests
<where>
<if test="sanityID != null" >
AND sanity_id = #{sanityID}
</if>
</where>
</select>
<resultMap id="imageDest" type="com.this.that.obj.SanityDest">
<result property="sanityId" column="sanity_id"/>
<association property="san" resultMap="fullSanity"/>
</resultMap>
<resultMap id="fullLocation" type="com.this.that.Sanity">
<result property="AC" column="sanitycode"/>
<result property="sidStr" column="sid"/>
<result property="rcode" column="rcode"/>
<result property="ridStr" column="rid"/>
<result property="cidStr" column="cid"/>
<result property="gid" column="gid"/>
</resultMap>
And here's what happens when I run the select directly against the database (mysql 5.5.24-0ubuntu0.12.04.1)
select sanity_id,sanitycode,ctid ,rid,rcode,cid,gid from sanity_tests WHERE sanity_id =9671;
+----------+-------------+-------+------+-------+-----+-----+
| sanity_id | sanitycode | sid | rid | rcode | cid | gid |
+----------+-------------+-------+------+-------+-----+-----+
| 9671 | LII | 22103 | 2500 | MM | 201 | BB |
| 9671 | UUU | 13127 | 141 | MN | 253 | SW |
+----------+-------------+-------+------+-------+-----+-----+
I also tried running the select without speicifying the sanity_id and mybatis seems to be only returning 1 object per sanity_id. What's up with that?