<resultMap class="com.framework.struts.form.TmStatisticsVO" id="tmStatisticsVo">
<result property="payTypeName" column="PAYTYPE_NAME" />
<result property="payAmount" column="PAY_AMOUNT" />
<result property="payStatus" column="PAY_STATUS" />
<result property="payTypeCode" column="PAYTYPE_CODE" />
<result property="successCount" column="successCount"/>
<result property="channelName" column="CHANNEL_NAME"/>
</resultMap> ----没有数据表映射的java类
<select id="getExport" resultMap="tmStatisticsVo">
<![CDATA[ select * from (select d.*,rownum as row_num from (]]>
<![CDATA[ select b.paytype_code as PAYTYPE_CODE,
b.paytype_name as PAYTYPE_NAME,
c.pay_status as PAY_STATUS,
count(*) as SUCCESSCOUNT,
sum(c.pay_amount) as PAY_AMOUNT ,
e.channel_name as CHANNEL_NAME
from tm_payorder a left join tm_paytype b on a.paytype_code=b.paytype_code
left join tm_payinfo c on a.order_id=c.order_id
left join tm_channel e on a.channel_id=e.channel_id
where
1=1
]]>
配置好,执行ibatis的queryForList(),返回一个List<TmStatisticsVO>集合,但是list每次都是个空的,拿不到,这是为什么
3 个解决方案
#1
<![CDATA[ select b.paytype_code as PAYTYPE_CODE,
b.paytype_name as PAYTYPE_NAME,
c.pay_status as PAY_STATUS,
count(*) as SUCCESSCOUNT,
sum(c.pay_amount) as PAY_AMOUNT ,
e.channel_name as CHANNEL_NAME
你这里的as 后面的列名错了。不应该使用数据库的列名了。应该使用你上面定义的property里的名字。
<result property="payTypeName" column="PAYTYPE_NAME" />
<result property="payAmount" column="PAY_AMOUNT" />
<result property="payStatus" column="PAY_STATUS" />
<result property="payTypeCode" column="PAYTYPE_CODE" />
<result property="successCount" column="successCount"/>
<result property="channelName" column="CHANNEL_NAME"/>
b.paytype_name as PAYTYPE_NAME,
c.pay_status as PAY_STATUS,
count(*) as SUCCESSCOUNT,
sum(c.pay_amount) as PAY_AMOUNT ,
e.channel_name as CHANNEL_NAME
你这里的as 后面的列名错了。不应该使用数据库的列名了。应该使用你上面定义的property里的名字。
<result property="payTypeName" column="PAYTYPE_NAME" />
<result property="payAmount" column="PAY_AMOUNT" />
<result property="payStatus" column="PAY_STATUS" />
<result property="payTypeCode" column="PAYTYPE_CODE" />
<result property="successCount" column="successCount"/>
<result property="channelName" column="CHANNEL_NAME"/>
#2
还是返回不了,它不会把查询后的每条结果封装成一个对象放在list集合里吗??
#3
LZ,你既然用了resultMap,你as的别名,就是map里面的 property,而不是后面的cloumn。
LZ你可以直接
User对象
String uname;
String uid;
<select returnClass="com.User">
select 字段 as uname,字段 as uid from 表
</select>
#1
<![CDATA[ select b.paytype_code as PAYTYPE_CODE,
b.paytype_name as PAYTYPE_NAME,
c.pay_status as PAY_STATUS,
count(*) as SUCCESSCOUNT,
sum(c.pay_amount) as PAY_AMOUNT ,
e.channel_name as CHANNEL_NAME
你这里的as 后面的列名错了。不应该使用数据库的列名了。应该使用你上面定义的property里的名字。
<result property="payTypeName" column="PAYTYPE_NAME" />
<result property="payAmount" column="PAY_AMOUNT" />
<result property="payStatus" column="PAY_STATUS" />
<result property="payTypeCode" column="PAYTYPE_CODE" />
<result property="successCount" column="successCount"/>
<result property="channelName" column="CHANNEL_NAME"/>
b.paytype_name as PAYTYPE_NAME,
c.pay_status as PAY_STATUS,
count(*) as SUCCESSCOUNT,
sum(c.pay_amount) as PAY_AMOUNT ,
e.channel_name as CHANNEL_NAME
你这里的as 后面的列名错了。不应该使用数据库的列名了。应该使用你上面定义的property里的名字。
<result property="payTypeName" column="PAYTYPE_NAME" />
<result property="payAmount" column="PAY_AMOUNT" />
<result property="payStatus" column="PAY_STATUS" />
<result property="payTypeCode" column="PAYTYPE_CODE" />
<result property="successCount" column="successCount"/>
<result property="channelName" column="CHANNEL_NAME"/>
#2
还是返回不了,它不会把查询后的每条结果封装成一个对象放在list集合里吗??
#3
LZ,你既然用了resultMap,你as的别名,就是map里面的 property,而不是后面的cloumn。
LZ你可以直接
User对象
String uname;
String uid;
<select returnClass="com.User">
select 字段 as uname,字段 as uid from 表
</select>