I'm looking for examples of how I can execute a jOOQ query with more than 22 rows.
http://www.jooq.org/doc/latest/manual/sql-building/column-expressions/row-value-expressions/
tells me it's possible, but I haven't been able to find an example.
Can anyone point me in the right direction?
As of jOOQ 3.7 (and there are currently no plans to change this), 22 is the maximum number of columns that can be fetched in a type safe way. Beyond 22, you can still execute queries, but jOOQ's API will no longer track the type of your records. For example:
// Still type safe
Result<Record22<Integer, String, ..., Integer>> result =
DSL.using(configuration)
.select(INT_COLUMN1, STRING_COLUMN2, ..., INT_COLUMN22)
.from(TABLE)
.fetch();
// Add one more column, and "lose" type safety
Result<Record> result =
DSL.using(configuration)
.select(INT_COLUMN1, STRING_COLUMN2, ..., INT_COLUMN22, STRING_COLUMN23)
.from(TABLE)
.fetch();
From an API user perspective, the API "feels" exactly the same way, regardless if you select 22 or less columns (type safely), or 23 or more columns (without type safety).
The difference might become most apparent when you compare type safe UNION
queries with non-type safe ones:
// Still type safe
Result<Record22<Integer, String, ..., Integer>> result =
DSL.using(configuration)
.select(INT_COLUMN1, STRING_COLUMN2, ..., INT_COLUMN21)
.from(TABLE)
.union(
// ^^^^^ compilation error here
select(INT_COLUMN1, STRING_COLUMN2, ..., INT_COLUMN21, INT_COLUMN22)
.from(TABLE))
.fetch();
// Add one more column, and "lose" type safety
Result<Record> result =
DSL.using(configuration)
.select(INT_COLUMN1, STRING_COLUMN2, ..., STRING_COLUMN23)
.from(TABLE)
.union(
// ^^^^^ This compiles, even if it's wrong
select(INT_COLUMN1, STRING_COLUMN2, ..., STRING_COLUMN23, STRING_COLUMN24)
.from(TABLE))
.fetch();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With