-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: write (how Kotlin JDSL is different from jOOq and QueryDSL) FAQ document #671
Changes from 3 commits
a033c79
b6699e8
c19c652
47626c6
c8452c0
bbe10ed
332d362
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,35 @@ | ||||||
# How is Kotlin JDSL different from jOOQ and QueryDSL? | ||||||
|
||||||
Unlike jOOq and QueryDSL, Kotlin JDSL does not generate a `Metadata Model (code generation) for writing queries. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please correct the Korean documentation as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've always wondered, are you Korean? Are you American? I like you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm Korean, and we're in the same dev community chat room. 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh.. :) now I know you. haha |
||||||
|
||||||
If you use code generation, you'll have to do the following: | ||||||
|
||||||
``` | ||||||
Modify tables and entities → | ||||||
Entity modification causes compile errors → | ||||||
Run Manven or Gradle task to regenerate the metadate → | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Could you please fix it in Korean documentation as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I was in a hurry and missed some parts haha... I'll correct it. |
||||||
Write query based on modified entity | ||||||
``` | ||||||
|
||||||
Then you might think about trying JPQL yourself, but that might not be a good idea. | ||||||
|
||||||
JPQL uses a string-based way of writing queries, which makes it impossible to detect errors at compile time. | ||||||
|
||||||
However, the Kotlin JDSL uses code generation and pure code-based query construction rather than string-based construction. | ||||||
|
||||||
This means that as soon as you modify an entity or field name, it is reflected in the query code, and the above inconvenience does not exist. | ||||||
|
||||||
It also adopts an ORM-based object-oriented query like JPQL, which supports specifications such as polymorphism and fetch joins. | ||||||
|
||||||
Therefore, the way we write queries also relies on object names and fields to query, rather than querying the table/column itself. | ||||||
|
||||||
Below is a table comparing the differences between Kotlin JDSL, QueryDSL, and jOOQ. | ||||||
|
||||||
|
||||||
|
||||||
| | Kotlin JDSL | QueryDSL | jOOQ | | ||||||
|----------------------|-------------|------------------------------------------------|------------------------------------------------| | ||||||
| Code Generation | ❌ | ✅ | ✅ | ✅ | | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, Code Generation itself is not good, but if it is marked with an X, it looks like JDSL is bad. I think it would be better to create a table that can highlight more advantages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, you are so delicate! I was thinking the same thing, rightly or wrongly, that the red X emoji would make anything about the benefits look negative. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| How to write queries | JPQL | SQL, SQL, JPQL | SQL | | ||||||
| Language support | Kotlin | All JVM languages including Java, Kotlin, etc. | All JVM languages including Java, Kotlin, etc. | | ||||||
| Type Stability | ✅ | ✅ | ✅ | ✅ | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Kotlin JDSL은 jOOQ, QueryDSL와 무엇이 다른가요? | ||
|
||
jOOq와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `Metadata Model(코드 제너레이션)`을 생성하지 않습니다. | ||
|
||
코드 제너레이션 방식을 사용하면 다음과 같은 수고로움이 있습니다: | ||
|
||
``` | ||
테이블과 엔티티 수정 → | ||
엔티티 수정으로 컴파일 오류 발생 → | ||
메타데이터를 다시 생성하기 위해 Manven 또는 Gradle 작업 실행 → | ||
수정된 엔티티를 기반으로 쿼리 작성 | ||
``` | ||
|
||
그러면 아마도 우리는 JPQL을 생각해볼 수도 있지만 이는 좋은 생각이 아닐 수 있습니다. | ||
|
||
JPQL은 문자열 기반의 쿼리 작성 방식을 사용하기 때문에, 컴파일 시점에 오류를 감지할 수 없습니다. | ||
|
||
하지만 Kotlin JDSL은 코드 제너레이션 방식과 문자열 기반 작성이 아닌 순수한 코드 기반으로 쿼리를 작성합니다. | ||
|
||
즉, 엔티티나 필드 이름을 수정하는 즉시 쿼리 코드에 반영이 되어 위와 같은 불편함이 존재하지 않습니다. | ||
|
||
또 JPQL과 같이 ORM 기반의 객체지향 쿼리를 채택하고 있어서 다형성, Fetch 조인 등의 스펙을 지원합니다. | ||
|
||
따라서 쿼리를 작성하는 방식 또한 테이블/컬럼 자체에 쿼리를 하는 것이 아닌 객체명과 필드에 의존하여 쿼리를 합니다. | ||
|
||
아래는 Kotlin JDSL과 QueryDSL, jOOQ의 차이점을 비교한 표입니다. | ||
|
||
| | Kotlin JDSL | QueryDSL | jOOQ | | ||
|----------|-------------|--------------------------|--------------------------| | ||
| 코드 제너레이션 | ❌ | ✅ | ✅ | | ||
| 쿼리 작성 방식 | JPQL | SQL, JPQL | SQL | | ||
| 언어 지원 | Kotlin | Java, Kotlin 등 모든 JVM 언어 | Java, Kotlin 등 모든 JVM 언어 | | ||
| 타입 안정성 | ✅ | ✅ | ✅ | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
jOOq
should bejOOQ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll reflect on it!