Skip to content

Commit

Permalink
Optimize QuerydslJpaPredicateExecutor.exists(Predicate)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff committed Dec 3, 2021
1 parent 8cd1388 commit 480b40e
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 480b40e

Please sign in to comment.