BooleanBuilder
BooleanBuilder builder = new BooleanBuilder();
if (usernameCond != null) {
builder.and(member.username.eq(usernameCond);
}
queryFactory
.selectFrom(member)
.where(builder)
.fetch();
Java
๋ณต์ฌ
Where ๋ค์ค ํ๋ผ๋ฏธํฐ
where ์ null ์ด ์์ผ๋ฉด ๋ฌด์๋๋ ํน์ง์ ํ์ฉ
queryFactory
.selectFrom(member)
.where(usernameEq(usernameCond))
.fetch();
private BooleanExpression usernameEq(String usernameCond) {
if (usernameCond == null) {
return null;
}
return member.username.eq(usernameCond);
}
Java
๋ณต์ฌ