@Test
public void querydslPredicateExecutor(){
Team teamA = new Team("teamA");
Team teamB = new Team("teamB");
em.persist(teamA);
em.persist(teamB);
Member member1 = new Member("member1", 10, teamA);
Member member2 = new Member("member2", 20, teamA);
Member member3 = new Member("member3", 30, teamB);
Member member4 = new Member("member4", 40, teamB);
em.persist(member1);
em.persist(member2);
em.persist(member3);
em.persist(member4);
QMember member = QMember.member;
//querydslPredicateExecutor사용
Iterable<Member> result = memberRepository.findAll(member.age.between(10, 40)
.and(member.username.eq("member1"))
);
for (Member findMember : result) {
System.out.println("member1= "+ findMember);
}
}
Spring Data JPA - Reference Documentation
굳이 사용할 필요가 없다.