<resultMap id="BaseResultMap" type="com.ts.entity.Funds">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_name_id" jdbcType="INTEGER" property="userNameId" />
<result column="funds_received_amount" jdbcType="DOUBLE" property="fundsReceivedAmount" />
<association property="user" javaType="com.ts.entity.UserName">
<id column="suser_name_id" jdbcType="INTEGER" property="userNameId" />
<result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
</association>
删除了部分的映射免得看起来太繁琐了。 如果遇到跟我相同问题的人,麻烦说下解决问题思路,感谢了
使用mybatis association一对一查询只查询到第一条数据
不一致的情况下更改了主键问题也不行。映射看了好几次都没有问题
就是差不多这样,查询出来数据库的值是4条 可是返回的list只有一条数据
select
f.funds_received_amount,
u.user_phone
from funds f ,user_name u ,(select MAX(funds_time) tim,user_name_id uid from funds GROUP BY user_name_id) maxtime
where f.user_name_id=u.user_name_id and f.user_name_id = maxtime.uid and f.funds_time=maxtime.tim
ORDER BY f.funds_received_amount DESC
后面更换为
select
f.*,
u.*
from funds f ,user_name u ,(select MAX(funds_time) tim,user_name_id uid from funds GROUP BY user_name_id) maxtime
where f.user_name_id=u.user_name_id and f.user_name_id = maxtime.uid and f.funds_time=maxtime.tim
ORDER BY f.funds_received_amount DESC
我也不知道问题出在哪儿 就查询出来了。希望如果遇到跟我一样的情况,可以多试一试,或者帮我解读下这个问题。虽然解决了 可是还是不知道为什么解决了