Directory

← Back

jOOQ for Vaadin

Integrates Vaadin with jOOQ to run type safe SQL queries.

Author

Rating

Popularity

<100

What is jOOQ?

jOOQ generates Java code from your database and lets you build type-safe SQL queries through its fluent API.

RecordGrid

The RecordGrid uses the table fields generated by jOOQ to create Vaadin Grid. It contains a Builder that can be used to create the Grid.

Example

RecordGrid<VEmployeeRecord> grid = 
        new RecordGrid.Builder<>(V_EMPLOYEE, dslContext)
            .withColumns(V_EMPLOYEE.EMPLOYEE_ID, V_EMPLOYEE.EMPLOYEE_NAME, V_EMPLOYEE.DEPARTMENT_NAME)
            .withSort(Map.of(V_EMPLOYEE.EMPLOYEE_NAME, true))
            .build();

For a fully integrated example, look at the showcase project.

VaadinJooqUtil

The VaadinJooqUtil class provides a convenient method to convert sort orders from a Vaadin DataProvider to OrderFields that can be used in a orderBy clause with jOOQ.

Example

dataProvider = new CallbackDataProvider<VEmployeeRecord, Condition>(
    query -> dsl
        .selectFrom(V_EMPLOYEE)
        .where(query.getFilter().orElse(DSL.noCondition()))
        .orderBy(orderFields(V_EMPLOYEE, query)) // usage of VaadinJooUtil
        .offset(query.getOffset())
        .limit(query.getLimit())
        .fetchStream(),
    
    query -> dsl
        .selectCount()
        .from(V_EMPLOYEE)
        .where(query.getFilter().orElse(DSL.noCondition()))
        .fetchOneInto(Integer.class),
        
    VEmployeeRecord::getEmployeeId)
        
    .withConfigurableFilter();

Sample code

RecordGrid<VEmployeeRecord> grid = 
        new RecordGrid.Builder<>(V_EMPLOYEE, dslContext)
            .withColumns(V_EMPLOYEE.EMPLOYEE_ID, V_EMPLOYEE.EMPLOYEE_NAME, V_EMPLOYEE.DEPARTMENT_NAME)
            .withSort(Map.of(V_EMPLOYEE.EMPLOYEE_NAME, true))
            .build();
dataProvider = new CallbackDataProvider<VEmployeeRecord, Condition>(
    query -> dsl
        .selectFrom(V_EMPLOYEE)
        .where(query.getFilter().orElse(DSL.noCondition()))
        .orderBy(orderFields(V_EMPLOYEE, query)) // usage of VaadinJooUtil
        .offset(query.getOffset())
        .limit(query.getLimit())
        .fetchStream(),
    
    query -> dsl
        .selectCount()
        .from(V_EMPLOYEE)
        .where(query.getFilter().orElse(DSL.noCondition()))
        .fetchOneInto(Integer.class),
        
    VEmployeeRecord::getEmployeeId)
        
    .withConfigurableFilter();

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

The project was moved under a new groupId ch.martinelli.oss

Released
2024-10-31
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 10+
Browser
N/A

jOOQ for Vaadin - Vaadin Add-on Directory

Integrates Vaadin with jOOQ to run type safe SQL queries. jOOQ for Vaadin - Vaadin Add-on Directory
## What is jOOQ? [jOOQ ](https://jooq.org/) generates Java code from your database and lets you build type-safe SQL queries through its fluent API. ## RecordGrid The RecordGrid uses the table fields generated by jOOQ to create Vaadin Grid. It contains a Builder that can be used to create the Grid. ### Example ```java RecordGrid grid = new RecordGrid.Builder<>(V_EMPLOYEE, dslContext) .withColumns(V_EMPLOYEE.EMPLOYEE_ID, V_EMPLOYEE.EMPLOYEE_NAME, V_EMPLOYEE.DEPARTMENT_NAME) .withSort(Map.of(V_EMPLOYEE.EMPLOYEE_NAME, true)) .build(); ``` For a fully integrated example, look at the [showcase project](https://github.com/simasch/vaadin-jooq-employee). ## VaadinJooqUtil The VaadinJooqUtil class provides a convenient method to convert sort orders from a Vaadin DataProvider to OrderFields that can be used in a orderBy clause with jOOQ. #### Example ```java dataProvider = new CallbackDataProvider( query -> dsl .selectFrom(V_EMPLOYEE) .where(query.getFilter().orElse(DSL.noCondition())) .orderBy(orderFields(V_EMPLOYEE, query)) // usage of VaadinJooUtil .offset(query.getOffset()) .limit(query.getLimit()) .fetchStream(), query -> dsl .selectCount() .from(V_EMPLOYEE) .where(query.getFilter().orElse(DSL.noCondition())) .fetchOneInto(Integer.class), VEmployeeRecord::getEmployeeId) .withConfigurableFilter(); ```
View on GitHub

jOOQ for Vaadin version 2.0.3

jOOQ for Vaadin version 2.0.4
Create SortOrder for a corresponding Java Record Thanks to Sebastian Kuehnau for his contribution

jOOQ for Vaadin version 2.1.1
The project was moved under a new groupId ch.martinelli.oss

Online