Skip to content
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

Merged

Conversation

progress0407
Copy link
Contributor

@progress0407 progress0407 commented Mar 13, 2024

Motivation

Modifications

  • wrote how-kotlin-jdsl-is-different-from-jooq-and-querydsl.md document.

English version

image

Korean version

image

Result

  • As described in the topic above(Modifications)

Closes

@progress0407 progress0407 changed the title docs: write (how Kotlin JDSL is different from jOOq and QueryDSL) FAQ… docs: write (how Kotlin JDSL is different from jOOq and QueryDSL) FAQ Document Mar 13, 2024
@progress0407 progress0407 changed the title docs: write (how Kotlin JDSL is different from jOOq and QueryDSL) FAQ Document docs: write (how Kotlin JDSL is different from jOOq and QueryDSL) FAQ document Mar 13, 2024
@@ -0,0 +1,34 @@
# 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.
Copy link
Member

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 be jOOQ

Copy link
Contributor Author

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!


Unlike jOOq and QueryDSL, Kotlin JDSL does not generate a `Metadata Model (code generation) for writing queries.

If you use code generation, you'll have to do the following.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
If you use code generation, you'll have to do the following.
If you use code generation, you'll have to do the following:

Copy link
Contributor Author

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!

Comment on lines 7 to 13
```
Modify tables / entities →
Compilation errors due to code and metacode mismatch →
Temporarily change all code associated with the modified code, e.g. by commenting it out, to make it compile.
Regenerate code
Remove the temporary code that was processed to pass compilation and replace it with working code.
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting is not required. Depending on how you run your Gradle task, you can generate metadata without commenting.

So I think it would be better to write something like this.

Modify table and entities -> Entity modification causes compile error -> Run Maven or Gradle task to regenerate metadata -> Write query based on modified entity

This way we have to run a Maven or Gradle test to modify the entity and use the modified entity. This causes an interruption in development, which can interrupt your thoughts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's something I was dissatisfied with when I wrote it too, I guess I didn't have an example of the essentials. Great, I've incorporated it.


In addition, JPQL uses a string-based query writing method, so it can pass compilation but may cause errors when running the web application.

However, Line-JDSL allows you to write queries based on pure code rather than using string-based writing and code generation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use Line-JDSL instead of Kotlin JDSL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it was created by Line, so I was a little confused about its official name. I'll fix that.

Remove the temporary code that was processed to pass compilation and replace it with working code.
```

In addition, JPQL uses a string-based query writing method, so it can pass compilation but may cause errors when running the web application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context doesn't seem to fit.

How about adding a sentence that connects the sentences?

"Then you might think about trying JPQL yourself, but that's not a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! I definitely think it feels natural because I included that sentence.

@progress0407
Copy link
Contributor Author

Wow... thank you so much for the feedback. I think this is very sincere feedback. We will reflect it soon!

@progress0407
Copy link
Contributor Author

Thanks for your patience!
I've fixed it.

@progress0407 progress0407 requested a review from shouwn March 17, 2024 16:20
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Unlike jOOq and QueryDSL, Kotlin JDSL does not generate a `Metadata Model (code generation) for writing queries.
Unlike jOOQ and QueryDSL, Kotlin JDSL does not generate a `Metadata Model (code generation) for writing queries.

Please correct the Korean documentation as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.. :) now I know you. haha

```
Modify tables and entities →
Entity modification causes compile errors →
Run Manven or Gradle task to regenerate the metadate →
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run Manven or Gradle task to regenerate the metadate
Run Maven or Gradle task to regenerate the metadata

Could you please fix it in Korean documentation as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@progress0407 progress0407 requested a review from waahhh March 18, 2024 06:50
@progress0407
Copy link
Contributor Author

Thanks for your review! I reflected it :)


| | Kotlin JDSL | QueryDSL | jOOQ |
|----------------------|-------------|------------------------------------------------|------------------------------------------------|
| Code Generation | ❌ | ✅ | ✅ | ✅ |
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, when I was compiling the reviews, I realized that there were a few unnatural things that I wanted to exclude, such as the following. T.T

image

Comment on lines 3 to 24
jOOQ와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `Metadata Model(코드 제너레이션)`을 생성하지 않습니다.

코드 제너레이션 방식을 사용하면 다음과 같은 수고로움이 있습니다:

```
테이블과 엔티티 수정 →
엔티티 수정으로 컴파일 오류 발생 →
메타데이터를 다시 생성하기 위해 Maven 또는 Gradle 작업 실행 →
수정된 엔티티를 기반으로 쿼리 작성
```

그러면 아마도 우리는 JPQL을 생각해볼 수도 있지만 이는 좋은 생각이 아닐 수 있습니다.

JPQL은 문자열 기반의 쿼리 작성 방식을 사용하기 때문에, 컴파일 시점에 오류를 감지할 수 없습니다.

하지만 Kotlin JDSL은 코드 제너레이션 방식과 문자열 기반 작성이 아닌 순수한 코드 기반으로 쿼리를 작성합니다.

즉, 엔티티나 필드 이름을 수정하는 즉시 쿼리 코드에 반영이 되어 위와 같은 불편함이 존재하지 않습니다.

또한 JPQL과 같이 ORM 기반의 객체지향 쿼리를 채택하고 있어서 다형성, Fetch 조인 등의 스펙을 지원합니다.

따라서 쿼리를 작성하는 방식 또한 테이블/컬럼 자체에 쿼리를 하는 것이 아닌 객체명과 필드에 의존하여 쿼리를 합니다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무래도 작성자 분과 제가 한국인이다 보니 영어로 이야기하면 커뮤니케이션을 하는데 시간이 오래 걸릴 것 같아 한글로 남깁니다.

먼저 이렇게 도움을 주셔서 감사합니다. 그리고 바쁜 시간 속에서도 리뷰사항을 계속 반영해주셔서 감사합니다. 🙏

코드 제너레이션

코드 제너레이션으로 인해 무엇이 안 좋은지를 적어주시면 좋겠습니다. 상황만 작성이되어 있으면 읽는 사람에 따라 각자 다른 생각을 가질 수 있기 때문에 작성자의 의도를 직접 문장으로 표현해 글쓴이가 무엇을 불편하게 생각하는지 명확하게 전달하는 것이 좋다고 생각합니다.

표현

현재 과정을 화살표로 표현해주셨는데요. 화살표는 한 줄로 표현될 때 효과적이라고 생각합니다. 지금은 개행으로 각각의 작업이 표시되어 있어 1. 2. 3.이나 - +을 이용해 나열하는 것이 더 좋을 것 같습니다.

JPQL

Kotlin JDSL은 향후(언제가될지 모르지만...) MySQL과 같은 Native Query로 지원할 생각을 가지고 있습니다. 그렇기 때문에 JPQL관련된 내용은 제거되면 좋겠다고 생각합니다.

만약 리뷰를 반영하기 어려우시면 말씀주세요. 위 내용은 작성해주신 내용을 기반으로 생각한 것이기 때문에, 머지 후에 제가 내용을 수정하겠습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅎㅎ 아닙니다. 제가 근래에 바쁜 일들이 곂쳐서 PR 반영이 많이 늦었던 것 같아요ㅠ 이제는 여유가 생겨서 괜찮습니다.

리뷰를 주고 받으면서 많은 것들을 느끼고 있습니다. 되려 기여자에게 꽤 좋은 기회라 생각이 듭니다.

코드네저레이션
네, 확실히 예시만으로 단점을 보이는 것보다 단점에 대한 정의(definition)(?)를 밝히는 게 좋다고 생각이 듭니다 :)

표현
확실히 그 동안 읽어 온 문서와 서적들을 떠올려 보면 화살표를 사용한 경우는 없었던 것 같아요. 정정하겠습니다.

JPQL
Native Query를 지원할 생각이 있으시군요! 알겠습니다.

@progress0407 progress0407 requested review from cj848 and shouwn March 19, 2024 09:28
@progress0407
Copy link
Contributor Author

English
Thanks for the reviews, everyone. I'm learning a lot.
However, I'm worried about the communication cost of the main open source developers.
If there are any ambiguous or insufficient parts that are difficult to convey in writing, it's okay if you can fix them in the near future. haha

Thank you.
philo dream.

Korean
ㅎㅎ 다들 리뷰 감사합니다. 여러 가지 배워가네요.
다만 걱정되는 건 오픈소스 메인 개발자 분들의 소통 비용이에요.
혹시나 글로 전달하기 애매모호한, 미흡한 부분 있으면 머지 후에 수정해주셔도 괜찮습니다. ㅎ

감사합니다.
philo 드림.

@@ -0,0 +1,30 @@
# Kotlin JDSL은 jOOQ, QueryDSL와 무엇이 다른가요?

jOOQ와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `Metadata Model(코드 제너레이션)`을 생성하지 않습니다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래 처럼 바꾸는 건 어떨까요?

Suggested change
jOOQ와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `Metadata Model(코드 제너레이션)`을 생성하지 않습니다.
jOOQ와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `메타 모델(Metadata Model)`의 생성을 요구하지 않습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다 :)


jOOQ와 QueryDSL과 다르게 Kotlin JDSL의 경우 쿼리 작성을 위해 `Metadata Model(코드 제너레이션)`을 생성하지 않습니다.

코드 제너레이션 방식을 사용하면 몇 가지 단점이 존재합니다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래와 같은 문장은 어떨까요?

Suggested change
코드 제너레이션 방식을 사용하면 몇 가지 단점이 존재합니다.
메타 모델을 생성하기 위해서는 일반적으로 코드 제너레이션 방식을 사용하게 되고 이는 몇 가지 단점을 가지고 있습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아.. 위에서 "코드 제너레이션"이라는 워딩을 뺀 대신에 여기서 이어나가는군요..?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다.

1. 프로젝트 초기 설정 복잡도 증가
2. 통상적인 빌드 프로세스 과정에 메타데이타터 생성 과정 추가

2번의 예시로 다음과 같은 수고로움이 있습니다:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2번의 예시로 다음과 같은 수고로움이 있습니다:
1번은 여러 플러그인들과 레퍼런스들로 단점을 해소할 수 있지만 2번은 그렇지 않습니다.
코드 제너레이션 방식을 사용할 경우 다음과 같이 `엔티티 수정``쿼리 작성` 사이에 추가 작업이 요구되고 이는 개발자의 생각의 흐름을 끊어지게 만듭니다.

Copy link
Contributor Author

@progress0407 progress0407 Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오! 사실 저도 1번의 단점을 적으면서... 애매하단 생각이 들었어요

예를 들면 아래의 이유들이 있는데...

  • 초기 구축만 끝나면, 이미 지나간 일이 되어버려서 큰 단점이 아님
  • 이전과 달리 GPT, Github등을 이용하면 쉽게 해결이 가능

옛날에는 분명 단점이라고 생각했던 부분인데... 이젠 불편한 정도더라구요.
(그렇다고 한 가지의 사례만 들면 또 적어보여서 ! )

그리고 12번 멘트 좋은 것 같아요. 실제로 흐름이 끊기거든요 ㅠ

Comment on lines 19 to 29
그러면 아마도 우리는 JPQL을 생각해볼 수도 있지만 이는 좋은 생각이 아닐 수 있습니다.

JPQL은 문자열 기반의 쿼리 작성 방식을 사용하기 때문에, 컴파일 시점에 오류를 감지할 수 없습니다.

하지만 Kotlin JDSL은 코드 제너레이션 방식과 문자열 기반 작성이 아닌 순수한 코드 기반으로 쿼리를 작성합니다.

즉, 엔티티나 필드 이름을 수정하는 즉시 쿼리 코드에 반영이 되어 위와 같은 불편함이 존재하지 않습니다.

또한 JPQL과 같이 ORM 기반의 객체지향 쿼리를 채택하고 있어서 다형성, Fetch 조인 등의 스펙을 지원합니다.

따라서 쿼리를 작성하는 방식 또한 테이블/컬럼 자체에 쿼리를 하는 것이 아닌 객체명과 필드에 의존하여 쿼리를 합니다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPQL 부분의 제거 혹은 문자열 기반의 쿼리 작성 방식으로 이야기를 풀어주시면 좋을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

문자열 기반의 쿼리 작성 방식으로 풀어보겠습니다! :)

@progress0407
Copy link
Contributor Author

하하 리뷰 감사합니다 :)

다시 리뷰 올려보았습니다 !

shouwn님의 리뷰에서는 정교한 논리가 느껴집니다..

이번에도 잘 부탁드립니다 :) ...

@progress0407 progress0407 requested a review from shouwn March 21, 2024 21:00
Copy link
Member

@shouwn shouwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make some changes after this PR is merged.

Thanks for following along with this long PR review!

@shouwn shouwn merged commit 88ede8d into line:develop Mar 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants