zoukankan      html  css  js  c++  java
  • 记录工作中sharing sphere/mybatis遇到的坑

    首先是如下这段sql,在navicat中执行没有问题,但是程序跑起来会出现映射问题,6个字段只有前2个能够成功映射

       select
            max(t.identification_name_encrypt) identificationName,
            trim(t.identification_num_encrypt) identificationNum ,
            sum(t.amount) amount ,
            t.org_id  orgId,
            max(t.org_name) orgName ,
            t.cal_rule calRule
            from  (
            select
            ia.identification_name_encrypt identificationName ,
            ia.identification_num_encrypt identificationNum ,
            ia.amount amount,
            cc.org_id orgId,
            cc.org_name orgName,
            cc.cal_rule calRule
            from labor_tax_channel_income_amount ia join
            labor_tax_channel_config cc on (ia.source_channel=cc.source_channel)  where cc.is_deleted=0 and ia.is_deleted=0 and period_name=#{periodName}
    

    把trim函数删掉后恢复正常,猜测是mybatis sql解析问题

    还是这段sql,发现在后面加了t.xxx后报错Can not find owner from table,错误来源是sharing sphere,但是在navicat执行依然是没问题的

       select
            max(t.identification_name_encrypt) identificationName,
            trim(t.identification_num_encrypt) identificationNum ,
            sum(t.amount) amount ,
            t.org_id  orgId,
            max(t.org_name) orgName ,
            t.cal_rule calRule
            from  (
            select
            ia.identification_name_encrypt identificationName ,
            ia.identification_num_encrypt identificationNum ,
            ia.amount amount,
            cc.org_id orgId,
            cc.org_name orgName,
            cc.cal_rule calRule
            from labor_tax_channel_income_amount ia join
            labor_tax_channel_config cc on (ia.source_channel=cc.source_channel)  where cc.is_deleted=0 and ia.is_deleted=0 and period_name=#{periodName})
            as t
            group by t.identificationNum,t.calRule,t.orgId
    
    

    上网一搜,发现其他人遇到过同样问题,提了issue,但是没能得到解决https://github.com/baomidou/mybatis-plus/issues/2585

  • 相关阅读:
    前端基础开发之HTML
    内置函数(二)
    html
    内置函数(一)
    二进制安装mysql
    .net Parallel并行使用
    MVC 枚举绑定 DropDownList
    MVC扩展Url.Action方法解决复杂对象参数问题
    Index.cshtml”处的视图必须派生自 WebViewPage 或 WebViewPage<TModel>。
    设置网站URL启动
  • 原文地址:https://www.cnblogs.com/CodeSpike/p/15153198.html
Copyright © 2011-2022 走看看