文章目录
-
- Mybatis异常合集
- 使用tk.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"