我的mapper里编了一个这个sql,但是我发现执行的时候总是会跟一个order by createTime desc,但是没有指定哪个表,总是报错,也不知道是哪里配置的。我自己在sql中的if里加
order by a.createTime desc 也不好使
select
a.*,
b.*
FROM
pfzf_organization a
LEFT JOIN organizationType b ON a.organizationTypeId = b.organizationTypeId
<where>
and 1 = 1
<if test="organizationTypeId!=null and organizationTypeId!=''">
and organizationTypeId =#{organizationTypeId}
</if>
</where>
select * from ( select tmp_page.*, rownum row_id from ( SELECT a.*, b.* FROM pfzf_organization a LEFT JOIN organizationType b ON a.organizationTypeId = b.organizationTypeId WHERE 1 = 1 order by createTime desc ) tmp_page where rownum <= ? ) where row_id > ?
去哪能改掉?
没有的话应该不会自己加上去的吧
检查下你是不是引用了mybatis的什么插件了自动添加了这项排序呢?
是用了插件或者说是mybatis plus增强包
这两天项目中也出现了这个问题,sql会自动拼接一个order by参数,后面排查发现是同事配置pageHelper的问题,其中有个supportMethodsArguments配置为true(默认为false),修改为false就行;看文档说的是匹配分页参数,但好像orderBy也匹配进去了。大家可以参考一下