1.底下这种in查询,Hibernate中分页查询,分页出现某些数据重复出现
and ap.dep_id in (select id from t_department connect by prior id = parent_id start with id in (‘8b8cf024607293f5016072d983d10007‘) )
//select id from t_department connect by prior id = parent_id start with id in (‘8b8cf024607293f5016072d983d10007‘) 查询当前部门,及其子部门所有的id
2.上面错误改成exists查询就好了
and exists( select id from t_department where ap.dep_id=id connect by priorid = parent_id start with id in (‘8b8cf024607293f5016072d983d10007‘ ) )
还有对于oracle查询来说,in查询中的数据最多为1000,超过1000也会报错,所以在知道数据不会超过1000的情况下,用in查询,如果已经预知到数据要超过1000,最好改为exists查询
微信公众号:
?
JAVA程序猿成长之路
分享资源,记录程序猿成长点滴。专注于Java,Spring,SpringBoot,SpringCloud,分布式,微服务。
原文地址:https://www.cnblogs.com/niugang0920/p/12194913.html
时间: 2024-10-29 05:00:17