kotlin - Jpa QueryDsl 다이나믹 쿼리로 where의 특정 조건 체크하기
kotlin 함수 ?.null { it } where 조건 안에서 특정 파라미터 값을 체크해 데이터 유무에 따라 사용할 수 있다. fun findByIdAndName(id: Long, name:String): List { return from(members) .where(members.id.eq(id), name?.let { members.name.eq(it) }) .fetch() } 코틀린에서 제공하는 함수를 queryDsl 쿼리문 안에서도 사용 가능하다. ?. : null 이 아닐 때 let { } : it 으로 자기 자신을 받아와서 객체의 상태를 변경할 수 있다. ?.let { null이 아닐 때 블럭을 실행한다. }
language/kotlin
2023. 3. 2. 22:11
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 문자열계산기
- 장애 대응
- port
- java.lang.NullPointerException: Parameter specified as non-null is null
- Cannot construct instance of
- JPA
- n+1
- checkout
- 배열
- insertMany
- ChatGPT
- QueryDSL
- Kotlin
- Java
- array
- 스프링오류
- junit5
- addFilterBefore
- FetchJoin
- MultipleBagFetchException
- document insert
- 추상클래스
- Git
- Linux
- MongoDB
- ?.let
- dto 클래스 생성자
- Spring Security
- spring boot 3
- insertOne
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함