mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
Merge pull request #118 from GOODBOY008/main
Use limit to improve exists performance
This commit is contained in:
commit
44c687e098
@ -418,7 +418,7 @@ public interface IService<T> {
|
|||||||
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
||||||
*/
|
*/
|
||||||
default boolean exists(QueryWrapper query) {
|
default boolean exists(QueryWrapper query) {
|
||||||
return SqlUtil.toBool(count(query));
|
return CollectionUtil.isNotEmpty(getMapper().selectListByQuery(query.limit(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -428,7 +428,7 @@ public interface IService<T> {
|
|||||||
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
||||||
*/
|
*/
|
||||||
default boolean exists(QueryCondition condition) {
|
default boolean exists(QueryCondition condition) {
|
||||||
return SqlUtil.toBool(count(condition));
|
return CollectionUtil.isNotEmpty(getMapper().selectListByCondition(condition,1L));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user