倔强的姑娘^o^ 2021-04-23 14:38 采纳率: 50%
浏览 236
已结题

mybatis 3.5.0 版本resultMap无法映射问题

1、版本

mybatis:3.5.0,mybatis-spring:2.0.6,jdk :1.8

2、问题

日志sql已经查询出来了

但是在后台断点处无法接收到查询出来的值

在sql里面对字段起了别名,使用resultMap进行映射无法正常设值,但是将resultMap改成了resultType就好用了

附上mybatis 代码

<resultMap id="BaseResultMap" type="com.stock.capital.enterprise.controlRules.dto.ControlRulesDto">
        <id column="id" property="id" jdbcType="VARCHAR" />
        <result column="trade_compliance_type" property="tradeComplianceType" jdbcType="VARCHAR" />
        <result column="company_id" property="companyId" jdbcType="VARCHAR" />
        <result column="compliance_id" property="complianceId" jdbcType="VARCHAR" />
        <result column="rule_status" property="ruleStatus" jdbcType="VARCHAR" />
        <result column="rule_number" property="ruleNumber" jdbcType="VARCHAR" />
        <result column="instructions" property="instructions" jdbcType="VARCHAR" />
        <result column="openAndAll" property="openAndAll" jdbcType="VARCHAR" />
        <result column="forcibly_prohibited_transactions" property="forciblyProhibitedTransactions" jdbcType="VARCHAR" />
        <result column="openPersonNum" property="openPersonNum" jdbcType="INTEGER" />
        <result column="allPersonNum" property="allPersonNum" jdbcType="INTEGER" />
        <result column="effect_start" property="effectStart" jdbcType="DATE" />
        <result column="invalid_end" property="invalidEnd" jdbcType="DATE" />
        <result column="company_name" property="companyName" jdbcType="VARCHAR" />
        <result column="company_code" property="companyCode" jdbcType="VARCHAR" />
    </resultMap>
<select id="queryControlRules"     parameterType="com.stock.capital.enterprise.controlRules.dto.ControlRulesDto" resultMap="BaseResultMap">
select totalCom.*,elseCom.ruleStatus,elseCom.forciblyProhibitedTransactions
from 
(
select s.zh_name as companyName,
s.`company_code` AS `companyCode`,
s.`create_time` AS `createTime`,
s.id AS `companyId`,
mm.id as complianceId,
mm.`trade_compliance_type` AS `tradeComplianceType`,
mm.`instructions` AS `instructions`,
mm.rule_number as ruleNumber,
mm.`effect_start` AS `effectStart`,
mm.`invalid_end` AS `invalidEnd`
,(
SELECT count(1) 
FROM edit_controls AS E 
inner join sa_person AS P 
on (P.id=E.person_id)
 where ( (E.if_effect = '1' )
 and (E.compliance_id = mm.id)
 and (E.company_id =s.id)
and (P.shareholder_status='Y'))
) as openPersonNum
,(
SELECT count(1) 
from edit_controls AS E 
join sa_person AS P 
on ( P.id=E.person_id )
where ( (E.compliance_id = mm.id )
and (E.company_id =s.id)
and (P.shareholder_status='Y')
)) as allPersonNum

from sa_company s
,(
select t.*
from trade_compliance t
left join total_rule tr 
on tr.rule_number = t.rule_number
where tr.`status`='1'
) as mm
where s.id!='96392852564612838'

) as totalCom
left join 
(
select 
scm.compliance_id as complianceId,
sc.id as companyId,
scm.rule_status as ruleStatus,
case scm.forcibly_prohibited_transactions when 1 then 1
else 0 end as forciblyProhibitedTransactions
from sa_company_compliance_map scm
left join sa_company sc
ON((`sc`.`id` = `scm`.`company_id`))
) as elseCom
on totalCom.companyId = elseCom.companyId
and totalCom.complianceId = elseCom.complianceId
<where>
<if test="companyName != null and companyName != ''"> 
totalCom.companyCode LIKE CONCAT('%', #{companyName}, '%') 
OR totalCom.companyName LIKE CONCAT('%', #{companyName}, '%') 
</if>
</where>
order by totalCom.createTime DESC,companyId DESC,totalCom.ruleNumber ASC
</select>

初步考虑是mybatis 版本之间的冲突,改了半天还是不行

有大佬知道为什么,怎么解决吗?

  • 写回答

2条回答 默认 最新

  • clever101 博客专家认证 2021-04-24 12:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月10日

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!