This major release is a great move towards better integration of SQL as a
language in Java. Unlike any other database abstraction framework, jOOQ now
formally supports the notion of "row value expressions". The jOOQ API uses
Xtend-generated API types from Row1 .. Row22, as well as Record1 ..
Record22 to
bring you even more compile-time typesafety on a record-level.

In SQL, you can typesafely write

SELECT * FROM t WHERE (t.a, t.b) = (1, 2)
SELECT * FROM t WHERE (t.a, t.b) OVERLAPS (date1, date2)
SELECT * FROM t WHERE (t.a, t.b) IN (SELECT x, y FROM t2)
UPDATE t SET (a, b) = (SELECT x, y FROM t2 WHERE ...)
INSERT INTO t (a, b) VALUES (1, 2)


In jOOQ, you can now (also typesafely!) write

select().from(t).where(row(t.a, t.b).eq(1, 2));
// Type-check here: ----------------->  ^^^^

select().from(t).where(row(t.a, t.b).overlaps(date1, date2));
// Type-check here: ------------------------> ^^^^^^^^^^^^

select().from(t).where(row(t.a, t.b).in(select(t2.x, t2.y).from(t2)));
// Type-check here: -------------------------> ^^^^^^^^^^

update(t).set(row(t.a, t.b), select(t2.x, t2.y).where(...));
// Type-check here: --------------> ^^^^^^^^^^

insertInto(t, t.a, t.b).values(1, 2);
// Type-check here: ---------> ^^^^


This also applies for existing API, which doesn't involve row value
expressions:

select().from(t).where(t.a.eq(select(t2.x).from(t2));
// Type-check here: ---------------> ^^^^

select().from(t).where(t.a.eq(any(select(t2.x).from(t2)));
// Type-check here: -------------------> ^^^^

select().from(t).where(t.a.in(select(t2.x).from(t2));
// Type-check here: ---------------> ^^^^


And for UNIONs

select(t1.a, t1.b).from(t1).union(select(t2.a, t2.b).from(t2));
// Type-check here: -------------------> ^^^^^^^^^^


These type-checks are preformed by your Java compiler, considering the
generic
type information of your SQL statement's Record data types. These include:

- Record1<T1>
- Record2<T1, T2>
- Record3<T1, T2, T3>
- ...
- Record22<T1, T2, T3, .., T22>

The highest degree of typesafety was chosen to be 22, to match Scala's
Tuple22,
Product22 and Function22 types. Higher degree records are still supported by
jOOQ, just without the additional typesafety.

This Record typesafety is applied to

- SELECT statements
- INSERT and MERGE statements: the VALUES() clause
- UPDATE statements: SET A = (SELECT...)
- UPDATE statements with row value expressions: SET (A, B) = (SELECT...)
- Quantified comparison predicates: ANY(SELECT...) and ALL(SELECT...)
- Comparison predicates: = (SELECT...)
- IN predicates: IN (SELECT...)
- BETWEEN predicates: BETWEEN (SELECT...) AND (SELECT...)
- Generated records
- The new VALUES() constructor
- Scala integration for conversion of jOOQ Record[N] to Scala's Tuple[N]

Apart from this major improvement, there had been many minor changes
throughout
the jOOQ API. Here are some important ones:

- Factory has been split into Factory (static QueryPart construction) and
  Executor (Query execution, "attached" QueryPart construction). This
greatly
  improves the overall DSL experience while allowing for more fine-grained
  Executor lifecycle control.
- A ConnectionProvider has been introduced as an abstraction of the JDBC
  Connection lifecycle. The standalone Connection and pooled DataSource
modes
  are still supported, but you can now inject your own ConnectionProvider
for
  more control.
- A lot of performance improvements have been implemented within the jOOQ
API
  removing most of the overhead caused by jOOQ when fetching data from JDBC
- A JDBC Mock API has been added to help you create simple unit tests for
your
  application built on top of jOOQ.
- A VALUES() constructor is now supported, and derived column lists to alias
  tables and columns in one go.
- The data type API has been greatly simplified. This allowed for the
  introduction of runtime precision, scale, and length information.
- CRUD has been improved through many more CRUD batch operations, explicit
  INSERT and UPDATE (in addition to store()), and explicit handling of
jOOQ's
  internal changed flags.

As this is a major release, some backwards-incompatibilities were
inevitable.
For those users among you, migrating from jOOQ 2.x to 3.0, here are a
couple of
useful hints:
http://www.jooq.org/doc/3.0/manual/reference/migrating-to-3.0/

Note, that for technical reasons, jOOQ 3.0.0-RC1 could not yet be
integration
tested with DB2, Ingres, and Sybase ASE. Any feedback, suggestions, bug
reports
on this user group are very welcome!

Note, that further code generation and model API improvements were
postponed to
a later release

For more details, please consider the release notes:
http://www.jooq.org/notes.php

Maintenance for the 2.x release stream will be continued for important
bugfixes and minor feature increments. Releases 2.6.3 and 2.7 will be
released shortly, some time this week.

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to