Monday, June 6, 2022
HomeProgramming3.15.0 Launch with Help for R2DBC, Nested ROW, ARRAY, and MULTISET varieties,...

3.15.0 Launch with Help for R2DBC, Nested ROW, ARRAY, and MULTISET varieties, 5 new SQL dialects, CREATE PROCEDURE, FUNCTION, and TRIGGER help and A lot Extra


R2DBC

What plenty of customers have been ready for: jOOQ 3.15 is reactive, due to the brand new native R2DBC integration. Current variations already applied the reactive streams Writer SPI, however now we’re not dishonest anymore. We’re not longer blocking. Simply wrap your R2DBC ConnectionFactory configured jOOQ question in a Flux (or any reactive streams API of your selection), and see what occurs.

Flux.from(ctx.choose(BOOK.TITLE).from(BOOK));

Each blocking (by way of JDBC) and non-blocking (by way of R2DBC) can work side-by-side, permitting customers to shortly a question between the 2 execution fashions with out anychanges to the question constructing logic.

Projecting ROW varieties, ARRAY of ROW Varieties, and MULTISETS

After having applied commonplace SQL/XML and SQL/JSON help in jOOQ 3.14, one other main milestone in taking SQL to the subsequent degree is now out there as anexperimental characteristic: Nesting collections utilizing the usual SQL MULTISET operator.

The operator is presently emulated utilizing SQL/XML or SQL/JSON. The ensuing paperwork are parsed once more when fetching them from JDBC. Future variations may even present native help (Informix, Oracle), and emulations utilizing ARRAY (varied dialects, together with PostgreSQL).

Think about this question in opposition to the Sakila database (https://www.jooq.org/sakila):

var outcome =
ctx.choose(
      FILM.TITLE,
      multiset(
        choose(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
        .from(ACTOR)
        .be part of(FILM_ACTOR).utilizing(ACTOR.ACTOR_ID)
        .the place(FILM_ACTOR.FILM_ID.eq(FILM.FILM_ID))
      ).as("actors"),
      multiset(
        choose(CATEGORY.NAME)
        .from(CATEGORY)
        .be part of(FILM_CATEGORY).utilizing(CATEGORY.CATEGORY_ID)
        .the place(FILM_CATEGORY.FILM_ID.eq(FILM.FILM_ID))
      ).as("movies")
   )
   .from(FILM)
   .orderBy(FILM.TITLE)
   .fetch();

You’re actually going to like Java 10’s var key phrase for these functions. What’s the kind of outcome? Precisely:

Consequence<Record3<
    String, 
    Consequence<Record2<String, String>>, 
    Consequence<Record1<String>>
>>

It comprises:

+---------------------------+--------------------------------------------------+---------------+
|title                      |actors                                            |movies          |
+---------------------------+--------------------------------------------------+---------------+
|ACADEMY DINOSAUR           |[(PENELOPE, GUINESS), (CHRISTIAN, GABLE), (LUCI...|[(Documentary)]|
|ACE GOLDFINGER             |[(BOB, FAWCETT), (MINNIE, ZELLWEGER), (SEAN, GU...|[(Horror)]     |
|ADAPTATION HOLES           |[(NICK, WAHLBERG), (BOB, FAWCETT), (CAMERON, ST...|[(Documentary)]|
 ...

Two collections have been nested in a single question with out producing any undesirable cartesian merchandise and duplication of knowledge. And keep tuned, we’ve added extra goodies! See this text on the way to map the above structural kind to your nominal varieties (e.g. Java 16 information) in a sort protected method, with out reflection!

Extra information right here:

New Dialects

We’ve added help for five (!) new SQLDialect’s. That’s unprecedented for any earlier minor launch. The brand new dialects are:

  • BIGQUERY
  • EXASOL
  • IGNITE
  • JAVA
  • SNOWFLAKE

Sure, there’s an experimental “JAVA” dialect. It’s principally helpful if you wish to translate your native SQL queries to jOOQ utilizing https://www.jooq.org/translate, and it can’t be executed. Within the close to future, we would add SCALA and KOTLIN as nicely, relying on demand.

BigQuery and Snowflake have been lengthy overdue by fashionable vote. The expedited EXASOL help has been sponsored by a buyer, which is a superb reminder that that is all the time an choice. You want one thing extra shortly? We are able to make it occur, even when the characteristic isn’t extremely popular on the roadmap.

Many different dialects have been introduced updated, together with REDSHIFT, HANA, VERTICA, and two have been deprecated: INGRES and ORACLE10G, as these develop much less and fewer fashionable.

Drop Java 6/7 help for Enterprise Version, require Java 11 in OSS Version

We’re cleansing up our help for outdated dependencies and options. Beginning with jOOQ 3.12, we supplied Java 6 and seven help solely to jOOQ Enterprise Version clients. With jOOQ 3.15, this help has now been eliminated, and Java 8 is the brand new baseline for business editions, Java 11 for the jOOQ Open Supply Version, which means the OSS Version is now lastly modular, and we get entry to little issues just like the Move API (see R2DBC) and @Deprecate(forRemoval, since).

Upgrading to Java 8 permits for thrilling new enhancements to our internals, as we are able to lastly use default strategies, lambdas, generalised goal kind inference, successfully closing, diamond operators, try-with-resources, string switches, and what not. Bettering our code base results in canine fooding, and that once more results in new options for you. For instance, we’ve put plenty of emphasis on ResultQuery.gather(), refactoring internals: https://weblog.jooq.org/use-resultquery-collect-to-implement-powerful-mappings/

There are new auxiliary varieties, like org.jooq.Rows and org.jooq.Data for extra purposeful transformation comfort. Extra features imply much less loops, and likewise much less ArrayList allocations.

On the similar time, we’ve began constructing a Java 17 prepared distribution for the business editions, which unlocks higher document kind help.

Refactoring of ResultQuery to work with DML

With all of the above goodies associated to Java 8, and a extra purposeful utilization of jOOQ, we’ve additionally lastly refactored our DML assertion kind hierarchy (INSERT,UPDATE, DELETE), to let their respective RETURNING clauses return an precise ResultQuery. Meaning now you can stream(), gather(), fetchMap() and subscribe() (by way of R2DBC) to your DML statements, and even put them within the WITH clause (in PostgreSQL).

Huge enhancements to the parser / translator use case

jOOQ’s secondary worth proposition is to make use of its parser and translator, as an alternative of the DSL API, which can also be out there without spending a dime on our web site: https://www.jooq.org/translate

With rising demand for this product, we’ve enormously improved the expertise:

  • The ParsingConnection not experimental
  • Batch is now doable
  • We’ve added a cache for enter/output SQL string pairs to closely velocity up the mixing
  • We’re now delaying bind variable kind inference to make use of precise PreparedStatement info. This produces extra correct outcomes, particularly when knowledge varieties aren’t recognized to the parser.
  • A brand new ParseListener SPI permits for hooking into the parser and prolong it with customized syntax help for column, desk, and predicate expressions.

CREATE PROCEDURE, FUNCTION, TRIGGER and extra procedural directions

Over the current releases, we’ve began engaged on procedural language extensions for the business distributions. Along with creating nameless blocks, we now additionally help all lifecycle administration DDL for procedures, features, and triggers, which may include procedural language logic.

That is nice information for those who’re supporting a number of RDBMS and wish to transfer some extra knowledge processing logic to the server facet in a vendor agnostic method.

Express JDBC driver dependencies to keep away from reflection

To get AOP prepared, we’re slowly eradicating inside reflection utilization, which means we’re experimenting with an express JDBC driver build-time dependency. This presently impacts:

  • Oracle
  • PostgreSQL
  • SQL Server

Solely drivers out there from Maven Central have been added as dependency to date.

Full launch notes right here.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments