Module org.jooq
Package org.jooq

Interface DSLContext

All Superinterfaces:
Scope
All Known Subinterfaces:
CloseableDSLContext
All Known Implementing Classes:
DefaultCloseableDSLContext, DefaultDSLContext

public interface DSLContext extends Scope
A contextual DSL providing "attached" implementations to the org.jooq interfaces.

Apart from the DSL, this contextual DSL is the main entry point for client code, to access jOOQ classes and functionality that are related to Query execution. Unlike objects created through the DSL type, objects created from a DSLContext will be "attached" to the DSLContext's Scope.configuration(), such that they can be executed immediately in a fluent style. An example is given here:


 DSLContext create = DSL.using(connection, dialect);

 // Immediately fetch results after constructing a query
 create.selectFrom(MY_TABLE).where(MY_TABLE.ID.eq(1)).fetch();

 // The above is equivalent to this "non-fluent" style
 create.fetch(DSL.selectFrom(MY_TABLE).where(MY_TABLE.ID.eq(1)));
 

The DSL provides convenient constructors to create a Configuration, which will be shared among all Query objects thus created. Optionally, you can pass a reusable Configuration to the DSL.using(Configuration) constructor. Please consider thread-safety concerns documented in Configuration, should you want to reuse the same Configuration instance in various threads and / or transactions.

DSLContext is a Scope type, mostly for convenience access to its underlying Configuration properties, including the Scope.data() map, which it shares with the Configuration. It does not have an independent lifecycle.

Author:
Lukas Eder
See Also: