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

  • 相关阅读:
    ol之天地图加载
    ol之地图定位
    ol之filter过滤获取feature
    android -- The import android.support cannot be resolved
    docker 笔记(3) -- 容器
    docker 笔记(2) -- 镜像
    docker 笔记(2) -- 镜像
    docker 笔记(0) -- 概述
    docker 笔记(1) -- 安装
    py3 与 Django 连接数据库: No module named 'MySQLdb'
  • 原文地址:https://www.cnblogs.com/CodeSpike/p/15153198.html
Copyright © 2011-2022 走看看