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

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 04:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

问题事件

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

悬赏问题

  • ¥30 SD中的一段Unet下采样代码其中的resnet是谁跟谁进行残差连接
  • ¥15 Unet采样阶段的res_samples问题
  • ¥60 Python+pygame坦克大战游戏开发实验报告
  • ¥15 R语言regionNames()和demomap()无法选中中文地区的问题
  • ¥15 Open GL ES 的使用
  • ¥15 我如果只想表示节点的结构信息,使用GCN方法不进行训练可以吗
  • ¥15 QT6将音频采样数据转PCM
  • ¥15 下面三个文件分别是OFDM波形的数据,我的思路公式和我写的成像算法代码,有没有人能帮我改一改,如何解决?
  • ¥15 Ubuntu打开gazebo模型调不出来,如何解决?
  • ¥100 有chang请一位会arm和dsp的朋友解读一个工程