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

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日

悬赏问题

  • ¥15 odoo17关于owl开发js代码问题
  • ¥15 光纤中多普勒频移公式的推导
  • ¥15 怎么制作一个人脸识别门禁系统
  • ¥20 大华dss监控平台网络关闭登不进去
  • ¥15 请使用蚁群算法解决下列问题,并给出我完整的代码
  • ¥20 关于php录入完成后,批量更新数据库
  • ¥15 请教往复密封润滑问题
  • ¥15 cocos creator发布ios包
  • ¥15 comsol压电材料数据
  • ¥35 用python实现除法算法中goldschmidt算法