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
711 stars 88 forks source link

The documentation guide lacks explanation of how to execute the query method. #568

Closed ilgolf closed 9 months ago

ilgolf commented 9 months ago

Background


I am using Kotlin JDSL for the first time and find that the documentation could be clearer in its explanation. Therefore, I want to modify and improve the clarity of this particular section.

Object


improve the clarity of this particular section.

Benefits


The description of "Execute the query section" is clearer, so users can easily follow it.

ilgolf commented 9 months ago

The following is the revised sentence that I want.

Execute the query

After building the query, you can use RenderContext to execute the query. For example, you can use JpqlRenderContext to execute the query:

val render = JpqlRenderer()

val context = JpqlRenderContext()

val rendered = render.render(query, context)

val jpaQuery: Query = entityManager.createQuery(rendered.query, query.returnType.java)

val result = jpaQuery.resultList

JpqlRender is a class that renders the query as String. his class extracts the query and parameters from the RenderContext and renders them as String.

RenderContext has elements for rendering the query as String. Kotlin JDSL provides JpqlRenderContext as the default RenderContext for the JPQL.

Creating RenderContext is expensive, so the Kotlin JDSL recommends creating it once and reusing it afterward. Since RenderContext is immutable, you can access RenderContext from multiple threads.

Spring Support

if you want to use Kotlin JDSL comfatable with Spring Data JPA or Spring Batch, please see Spring Support.

shouwn commented 9 months ago

Hi ilgolf. Thank you for your interest in Kotlin JDSL.

I like the way you've written it - it shows how to execute the query, but also explains the core components that Kotlin JDSL provides.

I will update the documentation today based on what you wrote!

shouwn commented 9 months ago

I've added the content to the docs, if there's anything else you'd like to see added, please open a new issue or reopen this issue.

image