使用Example_where_Cause出现 Column 'goods_id' in where clause is ambiguous解决办法

2023-05-16

 改写SSM项目https://www.bilibili.com/video/BV18J411k7SF?from=search&seid=7715680395343362130出现

Column 'goods_id' in where clause is ambiguous解决办法

原因分析及解释:https://www.bilibili.com/video/av925559812

P22 商品加入购物车前端处理 空降9分42

<select id="selectByExample" parameterType="com.damu.xiaomi.entry.GoodsCartExample" resultMap="BaseResultMapWithGoodsimage">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 10 19:17:22 CST 2019.
    -->
    select gc.id, gc.goods_id,  gc.add_date, gc.buy_count, gc.subtotal, gc.consumer_id,
    gi.id giid, gi.path, gi.title, gi.alt, gi.goods_id gigid
    from xiaomi.goods_cart gc
    left join xiaomi.goods_images gi
    on gc.goods_id = gi.goods_id
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
 <resultMap id="BaseResultMapWithGoodsimage" type="com.damu.xiaomi.entry.GoodsCart">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 10 19:17:22 CST 2019.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="buy_count" jdbcType="INTEGER" property="buyCount" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="add_date" jdbcType="TIMESTAMP" property="addDate" />
    <result column="subtotal" jdbcType="DOUBLE" property="subtotal" />
    <result column="consumer_id" jdbcType="INTEGER" property="consumerId" />
    <collection property="goodsImages" ofType="com.damu.xiaomi.entry.GoodsImages">
      <id column="giid" property="id"/>
      <result column="path" property="path"/>
      <result column="title" property="title"/>
      <result column="alt" property="alt"/>
    </collection>
  </resultMap>

sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 10 19:17:22 CST 2019.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>

解决办法::在mysql 生成视图

create view  v_goodcartinfo as(
    select gc.id, gc.goods_id,  gc.add_date, gc.buy_count, gc.subtotal, gc.consumer_id,
    gi.id giid, gi.path, gi.title, gi.alt, gi.goods_id gigid
    from xiaomi.goods_cart gc
    left join xiaomi.goods_images gi
    on gc.goods_id = gi.goods_id 
)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用Example_where_Cause出现 Column 'goods_id' in where clause is ambiguous解决办法 的相关文章

随机推荐

  • FFmpeg Android编译运行出现 Abort message: 'JniInvocation instance already initialized'

    signal 5 SIGTRAP code 1 TRAP BRKPT fault addr 0x272000000d03 Abort message JniInvocation instance already initialized 把
  • layui图标用法总结

    本文参考官方文档 layui图标使用官方文档 xff0c 建议先看此文章 xff0c 并结合本文的前两个步骤使用即可 1 下载layui js相关文档 xff0c layui js下载 xff0c 下载之后里面的内容如下 xff1a 只需要
  • Eggjs学习系列(一) 使用TypeScript快速入门

    Eggjs学习系列 xff08 一 xff09 使用TypeScript快速入门 Eggjs是一个node的渐近式开发框架 xff0c 用于服务端开发 而 TypeScript 是 JavaScript的超集 xff0c 在兼容 JavaS
  • Golang实现小型CMS内容管理功能(二):前端接入百度ueditor富文本编辑器

    当我们把接口都做好以后 xff0c 我们需要去开发前端界面 添加文章功能里面 xff0c 最重要的就是文章内容部分 xff0c 需要配置上富文本编辑器 xff0c 这样才能给我们的内容增加样式 下载ueditor代码 ueditor已经很久
  • 网络分析中数据包结构(含七层模型)

    七层模型 xff1a 包 Packet 是TCP IP协议通信传输中的数据单位 xff0c 一般也称 数据包 有人说 xff0c 局域网中传输的不是 帧 Frame 吗 xff1f 没错 xff0c 但是TCP IP协议是工作在OSI模型第
  • ubuntu下PyCharm遇到问题

    第三方库没有自动补全功能 xff08 autocomplete xff09 190921补充 xff1a 这个问题就是环境配置的问题当初真是无知 原因 xff1a PyCharm的人工编译环境和程序的运行环境不是同一个 xff08 说的太不
  • 用java简单的实现单链表的基本操作

    此代码仅供参考 xff0c 如有疑问欢迎评论 xff1a package com tyxh link 节点类 public class Node protected Node next 指针域 protected int data 数据域
  • 算法:海量日志数据,提取出某日访问百度次数最多的那个IP

    首先是这一天 xff0c 并且是访问百度的日志中的IP取出来 xff0c 逐个写入到一个大文件中 注意到IP是32位的 xff0c 最多有个2 32个IP 同样可以采用映射的方法 xff0c 比如模1000 xff0c 把整个大文件映射为1
  • 使用JUnit测试预期异常

    开发人员常常使用单元测试来验证的一段儿代码的操作 xff0c 很多时候单元测试可以检查抛出预期异常 expected exceptions 的代码 在Java语言中 xff0c JUnit是一套标准的单元测试方案 xff0c 它提供了很多验
  • BlockingQueue深入分析

    1 BlockingQueue 定义的常用方法如下 抛出异常特殊值阻塞超时插入add e offer e put e offer e time unit 移除remove poll take poll time unit 检查element
  • 聚合类新闻客户端产品功能点详情分析

    产品功能点 功能 今日头条 百度新闻 鲜果 ZAKER 媒体订阅 个性化内容推荐 个性化订阅 RSS 视频新闻 评论盖楼 搜索新闻 离线下载 地方新闻 一键分享 收藏 推送 天气 夜间模式 线上活动 主题设置 感兴趣 语音读文章 字体设置
  • 聚合类新闻客户端初体验

    初体验的产品 xff1a 今日头条 ios3 6 百度新闻 ios4 4 0 ZAKER ios4 4 5 鲜果 ios3 8 7 中搜搜悦 ios4 0 1 Flipboard ios2 3 9 1 Flipboard 一款国外很火的ap
  • 聚合类新闻客户端的改进

    zaker和鲜果是最早的聚合类新闻产品 xff0c 前几年发展很快 xff0c 迅速占领了市场 xff0c 但近两年发展变得缓慢 xff0c 而今日头条自发布以来才两年 xff0c 用户量就迅速超过了zaker和鲜果 xff0c 使用起来非
  • 单例模式优缺点

    主要优点 xff1a 1 提供了对唯一实例的受控访问 2 由于在系统内存中只存在一个对象 xff0c 因此可以节约系统资源 xff0c 对于一些需要频繁创建和销毁的对象单例模式无疑可以提高系统的性能 3 允许可变数目的实例 主要缺点 xff
  • 适配器模式优缺点

    优点 xff1a 1 将目标类和适配者类解耦 2 增加了类的透明性和复用性 xff0c 将具体的实现封装在适配者类中 xff0c 对于客户端类来说是透明的 xff0c 而且提高了适配者的复用性 3 灵活性和扩展性都非常好 xff0c 符合开
  • Oracle 的 Round函数

    Round函数用法 xff1a 截取数字 格式如下 xff1a ROUND xff08 number decimals xff09 其中 xff1a number 待做截取处理的数值 decimals 指明需保留小数点后面的位数 可选项 x
  • Ubuntu安装卸载软件

    VMware 1 首先 xff0c 官网下载 vmware 虚拟机 2 转到下载目录下 给vmware升权限 sudo chmod 43 x VMware Workstation Full 15 1 0 13591040 x86 64 bu
  • eclipse报错:Failed to load the JNI shared library

    电脑自装系统以来 xff0c 好久没有写java代码了 xff0c 所以一直也没用 eclipse IDE xff0c 今天将eclipse打开 xff0c 报了个问题 xff0c Failed to load the JNI shared
  • ACM 鸡兔同笼 线性代数linear algebra

    想模仿线性代数变化的步骤写程序但总感觉失去了灵魂 java Scanner sc 61 new Scanner System in int head 61 sc nextInt int leg 61 sc nextInt int arr 6
  • 使用Example_where_Cause出现 Column 'goods_id' in where clause is ambiguous解决办法

    改写SSM项目https www bilibili com video BV18J411k7SF from 61 search amp seid 61 7715680395343362130出现 Column 39 goods id 39