-
Notifications
You must be signed in to change notification settings - Fork 6
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
Internally, how SQL queries are eventually executed by JOOQ? #1
Comments
I'll answer to this issue. |
I have the intention to close the issue. |
I'll answer this issue. |
2 similar comments
I'll answer this issue. |
I'll answer this issue. |
I'll answer this issue |
1 similar comment
I'll answer this issue |
The following content will try to explain how JOOQ execute SQL queries. Technical explanationsAccording to the documentation, JOOQ provides a SQL Builder to "integrate SQL itself as an "internal domain specific language" directly into Java". JOOQ is actually wrapping a JDBC. When you're doing a SQL query, the wrapped JDBC will call executable objects "java.sql.Statement". The documentation splits it into three different types.
ExamplesLet's get some examples to understand how does it work.
Using SQL SELECT 1 FROM BOOK Using JOOQ create.selectOne().from(BOOK); JOOQ, to simplify the query writing process, uses obvious function names.
Using SQL SELECT AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, COUNT(*)
FROM AUTHOR
JOIN BOOK ON AUTHOR.ID = BOOK.AUTHOR_ID
WHERE BOOK.LANGUAGE = 'DE'
AND BOOK.PUBLISHED > '2008-01-01'
GROUP BY AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME
HAVING COUNT(*) > 5
ORDER BY AUTHOR.LAST_NAME ASC NULLS FIRST
LIMIT 2
OFFSET 1
FOR UPDATE Using JOOQ Factory create = new Factory(connection, dialect);
create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count())
.from(AUTHOR)
.join(BOOK).on(BOOK.AUTHOR_ID.equal(AUTHOR.ID))
.where(BOOK.LANGUAGE.equal("DE"))
.and(BOOK.PUBLISHED.greaterThan("2008-01-01"))
.groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.having(count().greaterThan(5))
.orderBy(AUTHOR.LAST_NAME.asc().nullsFirst())
.limit(2)
.offset(1)
.forUpdate(); Complementary informationQuerying SQL with JOOQ is well documented and you can get a lot of information following this link here. Sources: |
Gigouni has a very good summary. JOOQ is an database-mapping software library in Java. JOOQ uses JDBC to execute SQL queries. JOOQ prevents SQL syntax errors. To see more, read https://blog.jooq.org/tag/jdbc/ |
No description provided.
The text was updated successfully, but these errors were encountered: