Jooq Beginner-DSL Core

Source: Internet
Author: User

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.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.


Dslcontext Dslcontext = dsl.using (connection);

result<record> fetch = (). 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.