사용자 도구

사이트 도구


java:querydsl

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:querydsl [2020/07/15 18:06]
kwon37xi [Native 조건 condition]
java:querydsl [2023/12/06 13:44] (현재)
kwon37xi [QueryDSL]
줄 5: 줄 5:
   * [[http://www.querydsl.com/static/querydsl/latest/reference/html/|QueryDSL Reference]]   * [[http://www.querydsl.com/static/querydsl/latest/reference/html/|QueryDSL Reference]]
   * Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, JDO and SQL in Java.   * Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, JDO and SQL in Java.
 +  * [[java:jpa:blaze_persistence|Blaze Persistence]] 도 참조.
 +  * [[https://github.com/infobip/infobip-spring-data-querydsl|infobip-spring-data-querydsl]] : 각종 SpringDataXXX 프로젝트에 querydsl 연동
 +
 +===== 프로젝트 이관 =====
 +  * 5.x 이후에 https://github.com/OpenFeign/querydsl 으로 프로젝트과 이관됐다.
 +  * 이로인해 ''groupId'' 도 ''io.github.openfeign.querydsl''로 변경되었다.
 +  * https://mvnrepository.com/artifact/io.github.openfeign.querydsl
  
 ===== Q-Types multi thread loading 시 dead lock ===== ===== Q-Types multi thread loading 시 dead lock =====
줄 90: 줄 97:
   * [[https://jojoldu.tistory.com/401|[Querydsl] Case When 사용하기]]   * [[https://jojoldu.tistory.com/401|[Querydsl] Case When 사용하기]]
   * ''CaseBuilder'' 사용.   * ''CaseBuilder'' 사용.
 +  * ''CaseBuilder'' 사용시 ''when''과, ''otherwise'' 는 ''?'' 파라미터로 안먹고 무조건 상수로만 먹는듯 보임.
 +  * 따라서, ''when''과 ''otherwise''가 DB 입장에서 봤을 때 동일한 타입이 되는 상수로 맞춰줘야 한다.
  
 +<code java>
 +// registerDate 가 DATE 컬럼 일때
 +// newRegisterDate 는 LocalDateTime.class
 +Expression<LocalDateTime> modifyDateTime = new CaseBuilder()
 +    .when(qUser.registerDate.eq(expectedRegisterDate))
 +    .then(qUser.registerDate) // DB 입장에서 DATE 컬럼
 +    .otherwise(
 +        // DB 입장에서 DATE 인 'TO_DATE' 함수를 사용해서 변경해줌. 상수값만
 +        // 들어가기 때문에 어쩔 수 없이 문자로 모든 것을 넣어줌
 +        Expressions.dateTimeTemplate(LocalDateTime.class, "to_date({0}, {1})",
 +            newDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
 +            Expressions.constant("yyyy-MM-dd HH:mm:ss"))
 +        );
 +</code>
 ===== @Embeddable의 필드 소스 생성 ===== ===== @Embeddable의 필드 소스 생성 =====
   * Embeddable안에 또 다른 Embeddable이 있을 경우, 더 자식쪽 Embeddable의 경우 명시적 컬럼 매핑(''@Column'')이 없으면 모델 소스 (Q*) 생성시에 더 자식쪽 Embeddable의 필드에 대한 모델 소스가 올바르게 생성되지 않았다.   * Embeddable안에 또 다른 Embeddable이 있을 경우, 더 자식쪽 Embeddable의 경우 명시적 컬럼 매핑(''@Column'')이 없으면 모델 소스 (Q*) 생성시에 더 자식쪽 Embeddable의 필드에 대한 모델 소스가 올바르게 생성되지 않았다.
java/querydsl.1594803972.txt.gz · 마지막으로 수정됨: 2020/07/15 18:06 저자 kwon37xi