For brand new customers working with jOOQ for the primary time, the variety of sorts within the jOOQ API could be overwhelming. The SQL language doesn’t have many such “seen” sorts, though if you consider SQL the best way jOOQ does, then they’re there simply the identical, however hidden from customers by way of an English model syntax.
This overview will listing a very powerful jOOQ sorts in a cheat sheet kind.
Configuration is the only most essential configuration kind, which incorporates references to all different varieties of configuration,
Settings, customized SPI implementations, JDBC or R2DBC
Connection, and so forth. SPIs embody:
And lots of extra, which you’ll be able to see from the
It’s made out there from each
Scope kind within the API, see beneath for particulars
Scope sorts are numerous sorts which are created “within the scope” of a
Configuration, and as such can present entry to all the
Configuration‘s contained objects and SPIs. This design permits for very versatile, programmatic dependency injection all through the internals of jOOQ. A few of the most essential
Scope sorts embody:
For different sorts, confer with the
Settings are largely scalar flags that specify detailed behaviour in jOOQ. Some choose examples embody:
As of jOOQ 3.17, there are over 160 such settings, so we are able to’t listing all of them right here. For extra particulars, confer with the
The DSL API is a very powerful API to work with jOOQ. It is available in 2 flavours.
The static DSL
DSL incorporates entry factors to each kind of
QueryPart development DSLs, together with:
… and much more. All of those sorts are constructed statically, and as such, they don’t have any
Configuration hooked up.
The “context” DSL
The “context” DSL, represented by the
DSLContext kind, solely affords developing
QueryPart sorts that revenue from being created “within the context” of a
Configuration. That is primarily simply together with:
Question that has been constructed from the
DSLContext kind could be executed instantly by utilizing
ResultQuery.fetch(), or many different execution strategies, together with asynchronous or reactive ones.
All through the DSL API, you will note so-called “Step” sorts, i.e. sorts with a “Step” suffix, equivalent to e.g.
SelectFromStep, which is the “Step” that provides entry to the
You need to by no means reference these sorts instantly, nor see them in your personal code. They’re intermediate DSL artifacts
QueryPart p1 = TABLE; QueryPart p2 = TABLE.COLUMN; QueryPart p3 = TABLE.COLUMN.eq(1);
The above expressions produce a extra particular kind than
QueryPart, which we’ll clarify after, however all of them lengthen
QueryPart is a sort that may be rendered within the context of a
String sql = ctx.render(TABLE.COLUMN.eq(1));
QueryPart subtypes embody:
can be utilized in a
FROM clause of a
SELECT assertion, or as a goal of a DML assertion, and extra. There are numerous totally different desk sorts, together with:
There are various extra potential desk expressions in jOOQ, all implementing the
kind. An instance of utilizing
Desk expressions is:
Desk<?> joined = CUSTOMER .be a part of(ADDRESS) .on(ADDRESS.CUSTOMER_ID.eq(CUSTOMER.CUSTOMER_ID));
Whereas most jOOQ statements received’t work with such native variables, it’s all the time attention-grabbing to keep in mind that with jOOQ, each question is a dynamic SQL question, and each SQL fragment is a totally self contained expression tree in Java, which could be assigned to any native variable or returned from a technique, and so forth.
And far more.
Situation is only a
Subject<Boolean> with some extra API particular to
Situation constructing, together with the opportunity of calling
Situation::or, and others. Varied clauses settle for
Situation explicitly, together with:
Row or row worth expression is used to mannequin a tuple of values each for:
Such tuples are helpful to create a structural kind that teams
expressions into teams of re-usable objects. Some dialects additionally assist nominal variants of this, known as UDT (Person Outlined Kind), and jOOQ can emulate UDTs by way of embeddable sorts.
ResultQuery is a
Question that may produce
Report values in numerous assortment types (e.g.
CompletionStage, and so forth.). It may be created from numerous
Question sorts by including the
- A SQL string is generated
- Bind values are sure
- Presumably, a
With the intention to execute a
Question, it should be hooked up to a
Configuration, which is completed most simply by creating the
Question from a
Consequence kind is a
Checklist<Report> with quite a lot of mapping comfort API. It fashions an eagerly fetched JDBC
ResultSet, which incorporates all the outcomes from the database and no extra reference to the
ResultSet itself. That is helpful when the outcome set is reasonably sized.
Cursor kind is an
Iterable< with comparable mapping comfort API because the
Consequence kind, nevertheless it incorporates an open JDBC
ResultSet, permitting for fetching information from the server in a lazy method. That is helpful when the outcome set is big.
is a base kind for a database file. It permits discipline primarily based entry of particular person attributes in addition to mapping comfort into customized information sorts. It specialises as:
Discovered this listing helpful? Bookmark it, as we’ll add extra sorts sooner or later in case new essential ideas come up.