###### 问题遇到的现象和发生背景
我的mapper里编了一个这个sql,但是我发现执行的时候总是会跟一个order by 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 > ?
###### 我的解答思路和尝试过的方法
###### 我想要达到的结果
怎么解决?
select
x1.*,
x2.fd_name fdExpertName
from
xd_expert_yeareval x1
left join xd_expert x2 on x2.fd_id = x1.fd_expert_id
<where>
x1.fd_is_delete = 0
<if test="vo != null and vo.fdExpertId != null and vo.fdExpertId != ''">
and x1.fd_expert_id = #{vo.fdExpertId}
</if>
</where>
order by x1.fd_create_time desc
上面是mapper中写的语句
实际运行时却多出了一个order by fd_create_time asc
SELECT * FROM ( SELECT TMP.*, ROWNUM ROW_ID FROM ( SELECT x1.*, x2.fd_name fdExpertName FROM xd_expert_yeareval x1 LEFT JOIN xd_expert x2 ON x2.fd_id = x1.fd_expert_id WHERE x1.fd_is_delete = 0 ORDER BY fd_create_time ASC, x1.fd_create_time DESC ) TMP WHERE ROWNUM <=?) WHERE ROW_ID > ?
ThreadLocal里面的分页信息未被使用,也未被clear.然后下一个请求进来后,恰好复用到了当时那个线程,就默认有了分页信息,导致了程序报错
在代码里全局搜一下"createTime“这个玩意,它不可能自动识别到这个字段的,一定是有哪里指定了具体的名称