Mybatis异常

Mybatis异常合集

1.Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column ‘id’ in order clause is ambiguous

;Column ‘id’ in order clause is ambiguous; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column ‘id’ in order clause is ambiguous] with root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column ‘id’ in order clause is ambiguou

SQL: select
a.name,b.name,a.protocol_type,a.mn,a.type,a.is_started,a.transfer_type
from cus_point a,cus_enterprise b where a.enterprise_id=b.id
and enterprise_id = ? order by id desc LIMIT ?

尝试解决

在这里插入图片描述

发现是后面拼接 order by id模棱两可

2.mybatis多表查询未成功

我的这里需要联查的企业名称未得到
在这里插入图片描述

2.1 sql语句两表查询成功,说明是mybatis映射问题

在这里插入图片描述

2.2 两表查询 自定义vo类来接收结果 用AS 来实现 别名映射

在这里插入图片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shbykj.springboot.common.repository.EnterprisePointVoMapper">

  <resultMap id="EnterprisePointVo" type="com.shbykj.springboot.common.pojo.EnterprisePointVo">
    <result column="id" property="id"/>
    <result column="enterpriseId" property="enterpriseId"/>
    <result column="userId" property="userId"/>
    <result column="name" property="name"/>
    <result column="mn" property="mn"/>
    <result column="type" property="type"/>
    <result column="pass" property="pass"/>
    <result column="num"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值