Search
Duplicate
๐Ÿงต

๋™์  ์ฟผ๋ฆฌ

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
๋ณต์‚ฌ