Mybatis异常

这篇博客汇总了Mybatis在实际使用中遇到的各种异常,包括MySQLIntegrityConstraintViolationException关于'Column 'id' in order clause is ambiguous'的问题,mybatis多表查询失败的解决办法,参数映射错误的排查,下拉框选择后获取undefined的注意点,onclick事件传递中文参数的处理,以及Thymeleaf模板解析异常的解决。同时,博主强调了mybatis映射配置的常见错误和tk.mybatis使用中出现的InstantiationException问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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" property="num"/>
    <result column="protocolType" property="protocolType"/>
    <result column="transferType" property="transferType"/>
    <result column="address" property="address"/>
    <result column="longitude" property="longitude"/>
    <result column="latitude" proper
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值