SpringBoot

QueryDSL like, contains

simba 2020. 10. 27. 17:52

like와 contains의 차이

like는 컬럼의 풀텍스트가 일치하는 것만 출력

앞뒤에 %를 붙이면 부분만 일치해도 리스트가 출력

contains는 like 앞뒤에 %를 붙인것과 동일한 결과가 출력된다.

public List<Student> findByNameLike(String name);

Hibernate:
select
student0_.id as id1_0_,
student0_.name as name2_0_,
student0_.roll_number as roll_number3_0_,
student0_.university as university4_0_
from
student student0_
where
student0_.name like ?

public List<Student> findByNameContaining(String name);


Hibernate:
select
student0_.id as id1_0_,
student0_.name as name2_0_,
student0_.roll_number as roll_number3_0_,
student0_.university as university4_0_
from
student student0_
where
student0_.name like ?