<typeAlias alias="zonedetail" type="org.model.zone.ZoneDetail" /><resultMap id="zonedetailMap" class="zonedetail">
<result property="id" column="id"/>
<result property="zoneName" column="zone_name"/>
<result property="zoneStyle" column="zone_style"/>
<result property="num" column="num" />
</resultMap><select id="listMyADDZoneByUserId" resultMap="zonedetailMap" >
<![CDATA[
select tbzd.id as id ,tbzd.zone_name as zoneName ,tbzd.zone_style as zoneStyle
,count(jbzd.user_id) as num
from jnt_bz_zone_detail jbzd left join
tbl_bz_zone_detail tbzd on jbzd.zone_id=tbzd.id
left join jnt_bz_zone_member jbzm on tbzd.id =
jbzm.zone_id
where jbzm.member_id is not null and jbzd.user_id = #user_id# and jbzd.type=1
group by tbzd.id, tbzd.zone_name, tbzd.zone_style
]]>
</select>
ZoneDetail.java private String zoneName; private String zoneLogo; private String descs; private int zoneStyle; private int joinMethod;private int articleMethod;private int num;省略setter /getter
问题:SQL语句是多表查询。三个主表,两个中间表。select 语句在数据库中查询是值 的, 但在程序中确查不出来。。
求高手帮忙解决下
,count(jbzd.user_id) as num4楼说的对,as后面的应该与配置文件里面的column对应,这里少了下划线。
你直接用resultClass="zonedetail" 得了,不用定义resultMap了.
只要sql中的字段与model中的相对应就ok了