i tried use existsByid
@GetMapping("/{memberId}")
public boolean getMember(@PathVariable("memberId") long memberId) {
return memberRepository.existsById(memberId);
}
and jpa send query like this
select
m1_0.member_id
from
member m1_0
where
m1_0.member_id=?
it doesn't show limit 1 so I declared the method using a custom JPQL Query with @Query like this and sent the Query
@Query()
boolean existsByMemberId(long memberId);
@GetMapping("/{memberId}")
public boolean getMember(@PathVariable("memberId") long memberId) {
return memberRepository.existsById(memberId);
}
and then query included limit 1
select
m1_0.member_id
from
member m1_0
where
m1_0.member_id=?
limit
?
so I just wonderd existsById include limit 1 but doesn't show in the query or doesn't include limit 1
It looks like a side-effect of overriding/declaring CRUD repository methods.
Either way,
limit 1is pointless for simpleexistsBy...methods.These methods are transformed to SQL
select count()...queries, which withoutgroup byalways return 1 and only 1 row.