line / kotlin-jdsl

Kotlin library that makes it easy to build and execute queries without generated metamodel
https://kotlin-jdsl.gitbook.io/docs/
Apache License 2.0
686 stars 85 forks source link

Support hibernate-reactive #24

Closed cj848 closed 2 years ago

cj848 commented 2 years ago

hibernate reactive is a library that allows reactive DB access while using the jpa criteria API as it is, and it looks like a good project to be supported by kotlin-jdsl.

We would like to support this library and provide reactive jdsl.

-- korean hibernate reactive 는 jpa criteria API 를 그대로 사용하면서 reactive 한 DB 접근을 할 수 있는 라이브러리로 kotlin-jdsl 에서 지원하기 좋은 프로젝트로 보입니다. 우리는 이 라이브러리를 지원해서 reactive 한 jdsl 을 제공하면 좋겠습니다.

cj848 commented 2 years ago

We conducted a review on hibernate reactive.

  1. If hibernate-reactive is used, QueryFactory cannot be used as it is.

    interface QueryFactory {
    fun <T> typedQuery(returnType: Class<T>, dsl: CriteriaQueryDsl<T>.() -> Unit): TypedQuery<T>
    fun <T> subquery(returnType: Class<T>, dsl: SubqueryDsl<T>.() -> Unit): SubqueryExpressionSpec<T>
    }

    This interface has a typedQuery method that returns a TypedQuery . TypedQuery of this method cannot be used as a means of retrieving query results in Hibernate Reactive.

  2. If hibernate-reactive is used, CriteriaQueryCreator cannot be utilized. This is because it is returning a TypedQuery as in No. 1.

  3. Since reactive JPA standard has not been released yet, too many modifications are needed to support hibernate-reactive in kotlin-jdsl right now, and it can only be used in hibernate-reactive and cannot be used in other implementations.

  4. Abstract tests conforming to the current JPA specification are made, but changes must occur based on the future reactive standard set.

Therefore, it has been concluded that it is difficult to apply right now.

If the reactive JPA standard comes out in the future, it is expected that it can be applied.

-- korean hibernate reactive 에 대한 검토를 진행 하였습니다.

  1. hibernate-reactive 를 사용할 경우 QueryFactory 를 그대로 사용할 수 없습니다

    interface QueryFactory {
    fun <T> typedQuery(returnType: Class<T>, dsl: CriteriaQueryDsl<T>.() -> Unit): TypedQuery<T>
    fun <T> subquery(returnType: Class<T>, dsl: SubqueryDsl<T>.() -> Unit): SubqueryExpressionSpec<T>
    }

    이 인터페이스는 TypedQuery 를 리턴하는 typedQuery 메소드가 존재합니다. 이 메소드의 TypedQuery 는 Hibernate Reactive 에서 쿼리 결과를 조회하는 수단으로 사용할 수 없습니다.

  2. hibernate-reactive 를 사용할경우 CriteriaQueryCreator를 활용할 수 없습니다. 1번과 마찬가지로 TypedQuery 를 리턴하고 있기 때문입니다.

  3. 아직 reactive JPA 표준이 나오지 않아서 당장은 kotlin-jdsl 에서 hibernate-reactive 를 지원하기에는 너무 많은 수정이 필요하기도 하고 hibernate-reactive 에서만 쓸 수 있고 그 외 구현체에서는 사용할수 없는 상황입니다.

  4. 현재 JPA 스펙에 맞춰진 Abstract 테스트들이 만들어져 있는데 향후 reactive 표준이 정해졌을때 기준으로 또 변경이 일어나야 합니다.

그러므로 결론적으로 당장은 지원하기는 어렵다는 것으로 도출 되었습니다.

향후 reactive JPA 표준이 나오게 된다면 적용해볼 수 있을 것으로 예상합니다.

cj848 commented 2 years ago

Refer to https://github.com/line/kotlin-jdsl/wiki/Support-Reactive-JPA

-- korean https://github.com/line/kotlin-jdsl/wiki/Support-Reactive-JPA 를 참고해주세요