Skip to content

Commit

Permalink
Optimize QuerydslJpaPredicateExecutor.exists.
Browse files Browse the repository at this point in the history
Fixes #2333
Original pull request #2373
  • Loading branch information
quaff authored and schauder committed Dec 3, 2021
1 parent fda5c5a commit 45b860f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.AbstractJPAQuery;
Expand Down Expand Up @@ -225,7 +226,7 @@ public long count(Predicate predicate) {
*/
@Override
public boolean exists(Predicate predicate) {
return createQuery(predicate).fetchCount() > 0;
return createQuery(predicate).select(Expressions.ONE).fetchFirst() != null;
}

/**
Expand Down

0 comments on commit 45b860f

Please sign in to comment.