diff --git a/jOOQ-website/manual-pdf/jOOQ-manual.fo.xml b/jOOQ-website/manual-pdf/jOOQ-manual.fo.xml
index 9f73f98e47..5c30c59812 100644
--- a/jOOQ-website/manual-pdf/jOOQ-manual.fo.xml
+++ b/jOOQ-website/manual-pdf/jOOQ-manual.fo.xml
@@ -485,6 +485,22 @@
+Table sources
+
+
+
+
+
+
+
+
+
+3.
+
+
+
+
+
Conditions
@@ -495,7 +511,7 @@
-3.
+4.
@@ -511,7 +527,7 @@
-4.
+5.
@@ -527,7 +543,7 @@
-5.
+6.
@@ -543,7 +559,7 @@
-6.
+7.
@@ -559,7 +575,7 @@
-7.
+8.
@@ -575,7 +591,7 @@
-8.
+9.
@@ -591,7 +607,7 @@
-9.
+10.
@@ -607,7 +623,7 @@
-10.
+11.
@@ -623,7 +639,7 @@
-11.
+12.
@@ -639,7 +655,7 @@
-12.
+13.
@@ -655,7 +671,7 @@
-13.
+14.
@@ -1842,8 +1858,8 @@ i.execute();
Example: INSERT SELECT syntax support
In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another:
-Insert i = create.insertInto(T_AUTHOR_ARCHIVE,
- create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
+Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
+ .select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
i.execute();
@@ -3736,19 +3752,30 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
org.jooq.SelectOnStep
is a top-level interface.
-// These join conditions are supported
+... keyFields);
+SelectJoinStep onKey(ForeignKey, ?> key);
+SelectJoinStep using(Field>... fields);
// The example, continued:
create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
.from(T_AUTHOR)
- .join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));
+ .join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));]]>
- See the section about
- Conditions
+
+ See the section about
+ conditions
to learn more about the many ways
- to create Conditions in jOOQ. Now we're half way through. As you can
+ to create Conditions in jOOQ.
+ See also the section about
+ table sources
+ to learn more about the various ways of creating JOIN
+ expressions
+
+
+ Now we're half way through. As you can
see above, we're back to the SelectJoinStep. This means, we can
re-iterate and add another JOIN clause, just like in SQL. Or we go on
to the next step, adding conditions in the
@@ -3903,10 +3930,75 @@ Record fetchOne();
.where(TBook.LANGUAGE.equal("DE"))
.orderBy(TBook.TITLE)
.fetchAny();
+
+
+3.2. Table sources
+3.2. Table sources
+
+ When OLTP selects/updates/inserts/deletes records in single tables, OLAP is all about
+ creating custom table sources or ad-hoc row types
+
+ Create complex and nested table sources with jOOQ
+
+ In the relational data model,
+ there are many operations performed on entities, i.e. tables in order to join them together
+ before applying predicates, renaming operations and projections. Apart from the convenience
+ methods for joining table sources in the
+ manual's section about the full SELECT syntax,
+ the Table type itself provides a
+ rich API for creating joined table sources. See an extract of the Table API:
+
+ table);
+TableOnStep join(String sql);
+TableOnStep join(String sql, Object... bindings);
+
+// All other JOIN types are equally overloaded with "String sql" convenience methods...
+TableOnStep leftOuterJoin(TableLike> table);
+TableOnStep rightOuterJoin(TableLike> table);
+TableOnStep fullOuterJoin(TableLike> table);
+
+// These JOIN types don't take any additional clause
+Table crossJoin(TableLike> table);
+Table naturalJoin(TableLike> table);
+Table naturalLeftOuterJoin(TableLike> table);
+Table naturalRightOuterJoin(TableLike> table);
+
+// Oracle and SQL Server also know PIVOT / UNPIVOT clauses for transforming a
+// table into another one using a list of PIVOT values
+PivotForStep pivot(Field>... aggregateFunctions);
+PivotForStep pivot(Collection extends Field>> aggregateFunctions);]]>
+
+
+ The TableOnStep type
+ contains methods for constructing the ON / ON KEY / USING clauses
+
+
+ using(Field>... fields);
+Table using(Collection extends Field>> fields);
+
+// The ON KEY clause is a "synthetic" clause that does not exist in any SQL dialect. jOOQ usually has all
+// foreign key relationship information to dynamically render "ON [ condition ... ]" clauses
+TableOnConditionStep onKey() throws DataAccessException;
+TableOnConditionStep onKey(TableField, ?>... keyFields) throws DataAccessException;
+TableOnConditionStep onKey(ForeignKey, ?> key);]]>
+
+
+ For more details about the PIVOT clause, see the
+ manual's section about the Oracle PIVOT syntax
+
-3.2. Conditions
-3.2. Conditions
+3.3. Conditions
+3.3. Conditions
The creation of conditions is the part of any database abstraction that
attracts the most attention.
@@ -4002,8 +4094,8 @@ T_BOOK.TYPE_CODE.in(2, 3, 5, 7, 11, 13) .and(T_BOOK.LANGUA
T_BOOK.TYPE_CODE.in(create.select(T_TYPES.CODE).from(T_TYPES)).and(T_BOOK.LANGUAGE.equal("EN"))));
-3.3. Aliased tables and fields
-3.3. Aliased tables and fields
+3.4. Aliased tables and fields
+3.4. Aliased tables and fields
Aliasing is at the core of SQL and relational algebra. When you join
the same entity multiple times, you can rename it to distinguish the
@@ -4084,8 +4176,8 @@ GROUP BY FIRST_NAME, LAST_NAME;
System.out.println("Books : " + record.getValue("books"));
-3.4. Nested SELECT using the IN operator
-3.4. Nested SELECT using the IN operator
+3.5. Nested SELECT using the IN operator
+3.5. Nested SELECT using the IN operator
Set equal operations are very common when you want to select multiple
records. The IN operator can also be used for semi-joins, though
@@ -4149,8 +4241,8 @@ create.select(T_BOOK.getFields())
-3.5. Nested SELECT using the EXISTS operator
-3.5. Nested SELECT using the EXISTS operator
+3.6. Nested SELECT using the EXISTS operator
+3.6. Nested SELECT using the EXISTS operator
The EXISTS operator is a bit different from all other SQL
elements, as it cannot really be applied to any object in a DSL.
@@ -4245,8 +4337,8 @@ SelectConditionStep orNotExists(Select<?> select);
-3.6. Other types of nested SELECT
-3.6. Other types of nested SELECT
+3.7. Other types of nested SELECT
+3.7. Other types of nested SELECT
Apart from the most common IN and EXISTS clauses that encourage
the use of nested selects, SQL knows a few more syntaxes to make use
of such constructs.
@@ -4389,8 +4481,8 @@ create.select(T_AUTHOR.ID, books)
-3.7. UNION and other set operations
-3.7. UNION and other set operations
+3.8. UNION and other set operations
+3.8. UNION and other set operations
Unions, differences and intersections are vital set operations taken from set theory.
jOOQ's set operation API
The
@@ -4542,8 +4634,8 @@ create.selectFrom(EMP).where(DEPT.equal("R&D")
different.
-3.8. Functions and aggregate operators
-3.8. Functions and aggregate operators
+3.9. Functions and aggregate operators
+3.9. Functions and aggregate operators
Highly effective SQL cannot do without functions. Operations on
VARCHAR, DATE, and NUMERIC types in GROUP BY or ORDER BY clauses allow
@@ -4697,8 +4789,8 @@ AggregateFunction varSamp(Field extends Number> field);
-3.9. Stored procedures and functions
-3.9. Stored procedures and functions
+3.10. Stored procedures and functions
+3.10. Stored procedures and functions
The full power of your database's vendor-specific extensions can hardly
be obtained outside of the
@@ -4776,8 +4868,8 @@ create.select(T_PERSON.NAME)
DSL either.
-3.10. Arithmetic operations and concatenation
-3.10. Arithmetic operations and concatenation
+3.11. Arithmetic operations and concatenation
+3.11. Arithmetic operations and concatenation
Your database can do the math for you. Most arithmetic operations are
supported, but also string concatenation can be very efficient if done
@@ -4848,8 +4940,8 @@ create.select(concat("A", "B", "C"));
-3.11. The CASE clause
-3.11. The CASE clause
+3.12. The CASE clause
+3.12. The CASE clause
The SQL standard supports a CASE clause, which works very similar to
Java's if-else statement. In complex SQL, this is very useful for value
@@ -4935,8 +5027,8 @@ ORDER BY CASE FIRST_NAME WHEN 'Paulo' THEN 1
.execute();
-3.12. Type casting
-3.12. Type casting
+3.13. Type casting
+3.13. Type casting
Many RDBMS allow for implicit or explicit conversion between types.
Apart from true type conversion, this is most often done with casting.
@@ -4980,8 +5072,8 @@ public class Factory {
}
-3.13. When it's just easier: Plain SQL
-3.13. When it's just easier: Plain SQL
+3.14. When it's just easier: Plain SQL
+3.14. When it's just easier: Plain SQL
jOOQ cannot foresee all possible vendor-specific SQL features for your
database. And sometimes, even jOOQ code becomes too verbose. Then, you
diff --git a/jOOQ-website/manual-pdf/jOOQ-manual.pdf b/jOOQ-website/manual-pdf/jOOQ-manual.pdf
index 603324b832..1d07852485 100644
Binary files a/jOOQ-website/manual-pdf/jOOQ-manual.pdf and b/jOOQ-website/manual-pdf/jOOQ-manual.pdf differ
diff --git a/jOOQ-website/manual-single-page/index.php b/jOOQ-website/manual-single-page/index.php
index 2006458365..01dd8760dd 100644
--- a/jOOQ-website/manual-single-page/index.php
+++ b/jOOQ-website/manual-single-page/index.php
@@ -154,6 +154,9 @@ function printContent() {
Complete SELECT syntax
+Table sources
+
+
Conditions
@@ -1026,8 +1029,8 @@ i.execute();
Example: INSERT SELECT syntax support
In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another:
-Insert i = create.insertInto(T_AUTHOR_ARCHIVE,
- create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
+Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
+ .select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
i.execute();
@@ -2620,6 +2623,9 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
// These join conditions are supported
SelectJoinStep on(Condition... conditions);
+SelectJoinStep onKey();
+SelectJoinStep onKey(TableField<?, ?>... keyFields);
+SelectJoinStep onKey(ForeignKey<?, ?> key);
SelectJoinStep using(Field<?>... fields);
// The example, continued:
@@ -2627,10 +2633,18 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
.from(T_AUTHOR)
.join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));
- See the section about
- Conditions
+
+ See the section about
+ conditions
to learn more about the many ways
- to create Conditions in jOOQ. Now we're half way through. As you can
+ to create Conditions in jOOQ.
+ See also the section about
+ table sources
+ to learn more about the various ways of creating JOIN
+ expressions
+
+
+ Now we're half way through. As you can
see above, we're back to the SelectJoinStep. This means, we can
re-iterate and add another JOIN clause, just like in SQL. Or we go on
to the next step, adding conditions in the
@@ -2785,8 +2799,71 @@ Record fetchOne();
.where(TBook.LANGUAGE.equal("DE"))
.orderBy(TBook.TITLE)
.fetchAny();
+
+3.2. Table sources
+ When OLTP selects/updates/inserts/deletes records in single tables, OLAP is all about
+ creating custom table sources or ad-hoc row types
+
+ Create complex and nested table sources with jOOQ
+
+ In the relational data model,
+ there are many operations performed on entities, i.e. tables in order to join them together
+ before applying predicates, renaming operations and projections. Apart from the convenience
+ methods for joining table sources in the
+ manual's section about the full SELECT syntax,
+ the Table type itself provides a
+ rich API for creating joined table sources. See an extract of the Table API:
+
+// These are the various supported JOIN clauses. These JOIN types
+// are followed by an additional ON / ON KEY / USING clause
+TableOnStep join(TableLike<?> table);
+TableOnStep join(String sql);
+TableOnStep join(String sql, Object... bindings);
+
+// All other JOIN types are equally overloaded with "String sql" convenience methods...
+TableOnStep leftOuterJoin(TableLike<?> table);
+TableOnStep rightOuterJoin(TableLike<?> table);
+TableOnStep fullOuterJoin(TableLike<?> table);
+
+// These JOIN types don't take any additional clause
+Table<Record> crossJoin(TableLike<?> table);
+Table<Record> naturalJoin(TableLike<?> table);
+Table<Record> naturalLeftOuterJoin(TableLike<?> table);
+Table<Record> naturalRightOuterJoin(TableLike<?> table);
+
+// Oracle and SQL Server also know PIVOT / UNPIVOT clauses for transforming a
+// table into another one using a list of PIVOT values
+PivotForStep pivot(Field<?>... aggregateFunctions);
+PivotForStep pivot(Collection<? extends Field<?>> aggregateFunctions);
+
+
+ The TableOnStep type
+ contains methods for constructing the ON / ON KEY / USING clauses
+
+
+// The ON clause is the most widely used JOIN condition. Provide arbitrary conditions as arguments
+TableOnConditionStep on(Condition... conditions);
+TableOnConditionStep on(String sql);
+TableOnConditionStep on(String sql, Object... bindings);
+
+// The USING clause is also part of the SQL standard. Use this if joined tables contain identical field names.
+// The USING clause is simulated in databases that do not support it.
+Table<Record> using(Field<?>... fields);
+Table<Record> using(Collection<? extends Field<?>> fields);
+
+// The ON KEY clause is a "synthetic" clause that does not exist in any SQL dialect. jOOQ usually has all
+// foreign key relationship information to dynamically render "ON [ condition ... ]" clauses
+TableOnConditionStep onKey() throws DataAccessException;
+TableOnConditionStep onKey(TableField<?, ?>... keyFields) throws DataAccessException;
+TableOnConditionStep onKey(ForeignKey<?, ?> key);
+
+
+ For more details about the PIVOT clause, see the
+ manual's section about the Oracle PIVOT syntax
+
+
-3.2. Conditions
+3.3. Conditions
The creation of conditions is the part of any database abstraction that
attracts the most attention.
@@ -2880,7 +2957,7 @@ Record fetchOne();
T_BOOK.TYPE_CODE.in(2, 3, 5, 7, 11, 13) .and(T_BOOK.LANGUAGE.equal("FR")).or(
T_BOOK.TYPE_CODE.in(create.select(T_TYPES.CODE).from(T_TYPES)).and(T_BOOK.LANGUAGE.equal("EN"))));
-3.3. Aliased tables and fields
+3.4. Aliased tables and fields
Aliasing is at the core of SQL and relational algebra. When you join
the same entity multiple times, you can rename it to distinguish the
various meanings of the same entity
@@ -2959,7 +3036,7 @@ GROUP BY FIRST_NAME, LAST_NAME;
System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));
-3.4. Nested SELECT using the IN operator
+3.5. Nested SELECT using the IN operator
Set equal operations are very common when you want to select multiple
records. The IN operator can also be used for semi-joins, though
@@ -3012,7 +3089,7 @@ create.select(T_BOOK.getFields())
-3.5. Nested SELECT using the EXISTS operator
The EXISTS operator is a bit different from all other SQL
+3.6. Nested SELECT using the EXISTS operator
The EXISTS operator is a bit different from all other SQL
elements, as it cannot really be applied to any object in a DSL.
The EXISTS operator for use in semi-joins or anti-joins
@@ -3077,7 +3154,7 @@ SelectConditionStep orNotExists(Select<?> select);
-3.6. Other types of nested SELECT
Apart from the most common IN and EXISTS clauses that encourage
+3.7. Other types of nested SELECT
Apart from the most common IN and EXISTS clauses that encourage
the use of nested selects, SQL knows a few more syntaxes to make use
of such constructs.
Comparison with single-field SELECT clause
@@ -3191,7 +3268,7 @@ create.select(T_AUTHOR.ID, books)
-3.7. UNION and other set operations
Unions, differences and intersections are vital set operations taken from set theory.
+3.8. UNION and other set operationsUnions, differences and intersections are vital set operations taken from set theory.
jOOQ's set operation API
The
org.jooq.Select API directly supports the UNION
@@ -3323,7 +3400,7 @@ create.selectFrom(EMP).where(DEPT.equal("R&D")
In this example, the notion of "nested SELECT" and "subselect" are slightly
different.
-3.8. Functions and aggregate operators
+3.9. Functions and aggregate operators
Highly effective SQL cannot do without functions. Operations on
VARCHAR, DATE, and NUMERIC types in GROUP BY or ORDER BY clauses allow
for very elegant queries.
@@ -3444,7 +3521,7 @@ AggregateFunction<BigDecimal> varSamp(Field<? extends Number> field)
-3.9. Stored procedures and functions
+3.10. Stored procedures and functions
The full power of your database's vendor-specific extensions can hardly
be obtained outside of the
database itself. Most modern RDBMS support
@@ -3511,7 +3588,7 @@ create.select(T_PERSON.NAME)
to embed stored procedures in SQL, they cannot be integrated in jOOQ's
DSL either.
-3.10. Arithmetic operations and concatenation
+3.11. Arithmetic operations and concatenation
Your database can do the math for you. Most arithmetic operations are
supported, but also string concatenation can be very efficient if done
already in the database.
@@ -3562,7 +3639,7 @@ create.select(concat("A", "B", "C"));
-3.11. The CASE clause
+3.12. The CASE clause
The SQL standard supports a CASE clause, which works very similar to
Java's if-else statement. In complex SQL, this is very useful for value
mapping
@@ -3637,7 +3714,7 @@ ORDER BY CASE FIRST_NAME WHEN 'Paulo' THEN 1
.orderBy(T_AUTHOR.FIRST_NAME.sortAsc("Paulo", "George"))
.execute();
-3.12. Type casting
+3.13. Type casting
Many RDBMS allow for implicit or explicit conversion between types.
Apart from true type conversion, this is most often done with casting.
@@ -3679,7 +3756,7 @@ public class Factory {
<T> Field<T> castNull(Class<? extends T> type);
}
-3.13. When it's just easier: Plain SQL
+3.14. When it's just easier: Plain SQL
jOOQ cannot foresee all possible vendor-specific SQL features for your
database. And sometimes, even jOOQ code becomes too verbose. Then, you
shouldn't hesitate to provide jOOQ with plain SQL, as you'd do with
diff --git a/jOOQ-website/manual/DSL/CONDITION/index.php b/jOOQ-website/manual/DSL/CONDITION/index.php
index f7df89806a..aebddb1602 100644
--- a/jOOQ-website/manual/DSL/CONDITION/index.php
+++ b/jOOQ-website/manual/DSL/CONDITION/index.php
@@ -20,7 +20,7 @@ function printContent() {
?>
Conditions are the SELECT's core business
@@ -114,7 +114,7 @@ T_BOOK.TYPE_CODE.in(2, 3, 5, 7, 11, 13) .and(T_BOOK.LANGUA
T_BOOK.TYPE_CODE.in(create.select(T_TYPES.CODE).from(T_TYPES)).and(T_BOOK.LANGUAGE.equal("EN"))));
SELECT from anonymous or ad-hoc types
@@ -109,6 +109,9 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
// These join conditions are supported
SelectJoinStep on(Condition... conditions);
+SelectJoinStep onKey();
+SelectJoinStep onKey(TableField<?, ?>... keyFields);
+SelectJoinStep onKey(ForeignKey<?, ?> key);
SelectJoinStep using(Field<?>... fields);
// The example, continued:
@@ -116,10 +119,18 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
.from(T_AUTHOR)
.join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));
- See the section about
- Conditions
+
+ See the section about
+ conditions
to learn more about the many ways
- to create Conditions in jOOQ. Now we're half way through. As you can
+ to create Conditions in jOOQ.
+ See also the section about
+ table sources
+ to learn more about the various ways of creating JOIN
+ expressions
+
+
+ Now we're half way through. As you can
see above, we're back to the SelectJoinStep. This means, we can
re-iterate and add another JOIN clause, just like in SQL. Or we go on
to the next step, adding conditions in the
@@ -276,7 +287,7 @@ Record fetchOne();
.fetchAny();
+
+ Create complex and nested table sources with jOOQ
+
+ In the relational data model,
+ there are many operations performed on entities, i.e. tables in order to join them together
+ before applying predicates, renaming operations and projections. Apart from the convenience
+ methods for joining table sources in the
+ manual's section about the full SELECT syntax,
+ the Table type itself provides a
+ rich API for creating joined table sources. See an extract of the Table API:
+
+// These are the various supported JOIN clauses. These JOIN types
+// are followed by an additional ON / ON KEY / USING clause
+TableOnStep join(TableLike<?> table);
+TableOnStep join(String sql);
+TableOnStep join(String sql, Object... bindings);
+
+// All other JOIN types are equally overloaded with "String sql" convenience methods...
+TableOnStep leftOuterJoin(TableLike<?> table);
+TableOnStep rightOuterJoin(TableLike<?> table);
+TableOnStep fullOuterJoin(TableLike<?> table);
+
+// These JOIN types don't take any additional clause
+Table<Record> crossJoin(TableLike<?> table);
+Table<Record> naturalJoin(TableLike<?> table);
+Table<Record> naturalLeftOuterJoin(TableLike<?> table);
+Table<Record> naturalRightOuterJoin(TableLike<?> table);
+
+// Oracle and SQL Server also know PIVOT / UNPIVOT clauses for transforming a
+// table into another one using a list of PIVOT values
+PivotForStep pivot(Field<?>... aggregateFunctions);
+PivotForStep pivot(Collection<? extends Field<?>> aggregateFunctions);
+
+
+ The TableOnStep type
+ contains methods for constructing the ON / ON KEY / USING clauses
+
+
+// The ON clause is the most widely used JOIN condition. Provide arbitrary conditions as arguments
+TableOnConditionStep on(Condition... conditions);
+TableOnConditionStep on(String sql);
+TableOnConditionStep on(String sql, Object... bindings);
+
+// The USING clause is also part of the SQL standard. Use this if joined tables contain identical field names.
+// The USING clause is simulated in databases that do not support it.
+Table<Record> using(Field<?>... fields);
+Table<Record> using(Collection<? extends Field<?>> fields);
+
+// The ON KEY clause is a "synthetic" clause that does not exist in any SQL dialect. jOOQ usually has all
+// foreign key relationship information to dynamically render "ON [ condition ... ]" clauses
+TableOnConditionStep onKey() throws DataAccessException;
+TableOnConditionStep onKey(TableField<?, ?>... keyFields) throws DataAccessException;
+TableOnConditionStep onKey(ForeignKey<?, ?> key);
+
+
+ For more details about the PIVOT clause, see the
+ manual's section about the Oracle PIVOT syntax
+
+
+
+
+
diff --git a/jOOQ-website/manual/DSL/TABLESOURCES/index.php b/jOOQ-website/manual/DSL/TABLESOURCES/index.php
new file mode 100644
index 0000000000..0d5609af3c
--- /dev/null
+++ b/jOOQ-website/manual/DSL/TABLESOURCES/index.php
@@ -0,0 +1,92 @@
+
+
+
+ Create complex and nested table sources with jOOQ
+
+ In the relational data model,
+ there are many operations performed on entities, i.e. tables in order to join them together
+ before applying predicates, renaming operations and projections. Apart from the convenience
+ methods for joining table sources in the
+ manual's section about the full SELECT syntax,
+ the Table type itself provides a
+ rich API for creating joined table sources. See an extract of the Table API:
+
+// These are the various supported JOIN clauses. These JOIN types
+// are followed by an additional ON / ON KEY / USING clause
+TableOnStep join(TableLike<?> table);
+TableOnStep join(String sql);
+TableOnStep join(String sql, Object... bindings);
+
+// All other JOIN types are equally overloaded with "String sql" argument methods...
+TableOnStep leftOuterJoin(TableLike<?> table);
+TableOnStep rightOuterJoin(TableLike<?> table);
+TableOnStep fullOuterJoin(TableLike<?> table);
+
+// These JOIN types don't take any additional clause
+Table<Record> crossJoin(TableLike<?> table);
+Table<Record> naturalJoin(TableLike<?> table);
+Table<Record> naturalLeftOuterJoin(TableLike<?> table);
+Table<Record> naturalRightOuterJoin(TableLike<?> table);
+
+// Oracle and SQL Server also know PIVOT / UNPIVOT clauses for transforming a
+// table into another one using a list of PIVOT values
+PivotForStep pivot(Field<?>... aggregateFunctions);
+PivotForStep pivot(Collection<? extends Field<?>> aggregateFunctions);
+
+
+ The TableOnStep type
+ contains methods for constructing the ON / ON KEY / USING clauses
+
+
+// The ON clause is the most widely used JOIN condition. Provide arbitrary conditions as arguments
+TableOnConditionStep on(Condition... conditions);
+TableOnConditionStep on(String sql);
+TableOnConditionStep on(String sql, Object... bindings);
+
+// The USING clause is also part of the SQL standard. Use this if joined tables contain identical field names.
+// The USING clause is simulated in databases that do not support it.
+Table<Record> using(Field<?>... fields);
+Table<Record> using(Collection<? extends Field<?>> fields);
+
+// The ON KEY clause is a "synthetic" clause that does not exist in any SQL dialect. jOOQ usually has all
+// foreign key relationship information to dynamically render "ON [ condition ... ]" clauses
+TableOnConditionStep onKey() throws DataAccessException;
+TableOnConditionStep onKey(TableField<?, ?>... keyFields) throws DataAccessException;
+TableOnConditionStep onKey(ForeignKey<?, ?> key);
+
+
+ For more details about the PIVOT clause, see the
+ manual's section about the Oracle PIVOT syntax
+
+
+
+
+
diff --git a/jOOQ-website/manual/DSL/index.php b/jOOQ-website/manual/DSL/index.php
index ccf4e6abaa..2ed8fdaf02 100644
--- a/jOOQ-website/manual/DSL/index.php
+++ b/jOOQ-website/manual/DSL/index.php
@@ -67,6 +67,9 @@ create.select()
Complete SELECT syntax
+Table sources
+
+
Conditions
diff --git a/jOOQ-website/manual/JOOQ/Query/index.php b/jOOQ-website/manual/JOOQ/Query/index.php
index f5d3e1b970..cd0003dbe9 100644
--- a/jOOQ-website/manual/JOOQ/Query/index.php
+++ b/jOOQ-website/manual/JOOQ/Query/index.php
@@ -311,8 +311,8 @@ i.execute();
Example: INSERT SELECT syntax support
In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another:
-Insert i = create.insertInto(T_AUTHOR_ARCHIVE,
- create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
+Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
+ .select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
i.execute();
diff --git a/jOOQ-website/manual/index.php b/jOOQ-website/manual/index.php
index 9dfc24fc05..446477ba6a 100644
--- a/jOOQ-website/manual/index.php
+++ b/jOOQ-website/manual/index.php
@@ -160,6 +160,9 @@ function printContent() {
Complete SELECT syntax
+Table sources
+
+
Conditions
diff --git a/jOOQ-website/src/main/resources/manual.xml b/jOOQ-website/src/main/resources/manual.xml
index 2d9cc2f68f..06bcd9675b 100644
--- a/jOOQ-website/src/main/resources/manual.xml
+++ b/jOOQ-website/src/main/resources/manual.xml
@@ -836,8 +836,8 @@ i.execute();
Example: INSERT SELECT syntax support
In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another:
-Insert i = create.insertInto(T_AUTHOR_ARCHIVE,
- create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
+Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
+ .select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.isTrue()));
i.execute();
@@ -2416,19 +2416,30 @@ create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
is a top-level interface.
-// These join conditions are supported
+... keyFields);
+SelectJoinStep onKey(ForeignKey, ?> key);
+SelectJoinStep using(Field>... fields);
// The example, continued:
create.select(T_AUTHOR.FIRST_NAME, T_AUTHOR.LAST_NAME, count())
.from(T_AUTHOR)
- .join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));
+ .join(T_BOOK).on(T_BOOK.AUTHOR_ID.equal(T_AUTHOR.ID));]]>
- See the section about
-
+
+ See the section about
+
to learn more about the many ways
- to create Conditions in jOOQ. Now we're half way through. As you can
+ to create Conditions in jOOQ.
+ See also the section about
+
+ to learn more about the various ways of creating JOIN
+ expressions
+
+
+ Now we're half way through. As you can
see above, we're back to the SelectJoinStep. This means, we can
re-iterate and add another JOIN clause, just like in SQL. Or we go on
to the next step, adding conditions in the
@@ -2587,6 +2598,74 @@ Record fetchOne();
+
+ Table sources
+
+ When OLTP selects/updates/inserts/deletes records in single tables, OLAP is all about
+ creating custom table sources or ad-hoc row types
+
+
+ Create complex and nested table sources with jOOQ
+
+ In the relational data model,
+ there are many operations performed on entities, i.e. tables in order to join them together
+ before applying predicates, renaming operations and projections. Apart from the convenience
+ methods for joining table sources in the
+ ,
+ the type itself provides a
+ rich API for creating joined table sources. See an extract of the Table API:
+
+ table);
+TableOnStep join(String sql);
+TableOnStep join(String sql, Object... bindings);
+
+// All other JOIN types are equally overloaded with "String sql" convenience methods...
+TableOnStep leftOuterJoin(TableLike> table);
+TableOnStep rightOuterJoin(TableLike> table);
+TableOnStep fullOuterJoin(TableLike> table);
+
+// These JOIN types don't take any additional clause
+Table crossJoin(TableLike> table);
+Table naturalJoin(TableLike> table);
+Table naturalLeftOuterJoin(TableLike> table);
+Table naturalRightOuterJoin(TableLike> table);
+
+// Oracle and SQL Server also know PIVOT / UNPIVOT clauses for transforming a
+// table into another one using a list of PIVOT values
+PivotForStep pivot(Field>... aggregateFunctions);
+PivotForStep pivot(Collection extends Field>> aggregateFunctions);]]>
+
+
+ The type
+ contains methods for constructing the ON / ON KEY / USING clauses
+
+
+ using(Field>... fields);
+Table using(Collection extends Field>> fields);
+
+// The ON KEY clause is a "synthetic" clause that does not exist in any SQL dialect. jOOQ usually has all
+// foreign key relationship information to dynamically render "ON [ condition ... ]" clauses
+TableOnConditionStep onKey() throws DataAccessException;
+TableOnConditionStep onKey(TableField, ?>... keyFields) throws DataAccessException;
+TableOnConditionStep onKey(ForeignKey, ?> key);]]>
+
+
+ For more details about the PIVOT clause, see the
+
+
+
+
+
+