Org.jooq.impl.DSL is the main class that generates all Jooq objects. It acts as a static factory to generate database table expressions, column expressions, conditional expressions, and other query parts. After Jooq 2.0, the static factory method was introduced in order to make the client code more approximate to SQL. When you use a DSL, you simply need to introduce all the static methods from the DSL class. Columns such as: Importstatic org.jooq.impl.dsl.*;
Dslcontext and DSLs are the main entry points for accessing JOOQ classes and functions.
Example: Create a field with a constant value, field<string> field = Dsl.val ("Hello World")
Condition Condition = dsl.exists (Dsl.select (Dsl.field ("username")), equivalent to SQL [select * from Shangfox_user where exists ( Select username from dual)]
table<record> table = dsl.table ("Shangfox_user");
Dslcontext Dslcontext = dsl.using (connection); Get database connection
Dslcontext quoted the org.jooq.Configuration. The configuration configures the behavior of Jooq when Jooq executes the query. Unlike Dslcontext and DSLs, Dslcontext allows you to create SQL statements that are already configured and ready for execution.
Gca
Dslcontext Dslcontext = dsl.using (connection);
result<record> fetch = Dslcontext.select (). from (table). WHERE ("Statu = 0"). and ("ID > 4340"). (Dsl.field ("Time"). ASC ()). Fetch ();
for (Object Aresult:fetch) {
record record = (record) Aresult;
System.out.println (record);
}
Detailed Demo
Come on. Winterchou.