This version of the manual is outdated. For the latest version, follow this link: http://www.jooq.org/doc/3.0/manual.
| The jOOQ User Manual. Multiple Pages : DSL or fluent API. Where SQL meets Java | previous : next |
# Overview
jOOQ ships with its own DSL (or Domain Specific Language) that simulates SQL as good as possible in Java. This means, that you can write SQL statements almost as if Java natively supported that syntax just like .NET's C# does with LINQ to SQL.
Here is an example to show you what that means. When you want to write a query like this in SQL:
-- Select all books by authors born after 1920, -- named "Paulo" from a catalogue: SELECT * FROM t_author a JOIN t_book b ON a.id = b.author_id WHERE a.year_of_birth > 1920 AND a.first_name = 'Paulo' ORDER BY b.title |
Result<Record> result =
create.select()
.from(T_AUTHOR.as("a"))
.join(T_BOOK.as("b")).on(a.ID.equal(b.AUTHOR_ID))
.where(a.YEAR_OF_BIRTH.greaterThan(1920)
.and(a.FIRST_NAME.equal("Paulo")))
.orderBy(b.TITLE)
.fetch();
|
You couldn't come much closer to SQL itself in Java, without re-writing the compiler. We'll see how the aliasing works later in the section about aliasing
# Table of contents
- Complete SELECT syntax
- Table sources
- Conditions
- Aliased tables and fields
- Nested SELECT using the IN operator
- Nested SELECT using the EXISTS operator
- Other types of nested SELECT
- UNION and other set operations
- Functions and aggregate operators
- Stored procedures and functions
- Arithmetic operations and concatenation
- The CASE clause
- Type casting
- When it's just easier: Plain SQL
| The jOOQ User Manual. Multiple Pages : DSL or fluent API. Where SQL meets Java | previous : next |
