How can I see the generated query?

Kotlin JDSL prints queries and parameters generated by DSL to the debug log. So you can see it by changing the log level of the com.linecorp.kotlinjdsl package to debug.

Because the parameters contained in the log are printed through the toString function, it can be difficult to identify the values unless toString function is overridden.

select(
    path(Book::isbn),
).from(
    entity(Book::class),
).where(
    path(Book::publishDate).between(
        OffsetDateTime.parse("2023-01-01T00:00:00+09:00"),
        OffsetDateTime.parse("2023-06-30T23:59:59+09:00"),
    ),
).orderBy(
    path(Book::isbn).asc(),
)
2023-01-01T00:00:00.000+09:00 DEBUG c.l.kotlinjdsl.render.jpql.JpqlRenderer  : The query is rendered.
SELECT Book.isbn FROM Book AS Book WHERE Book.publishDate BETWEEN :param1 AND :param2 ORDER BY Book.isbn ASC
{param1=2023-01-01T00:00+09:00, param2=2023-06-30T23:59:59+09:00}

Last updated