EzjOOQ

Simple CRUD Repository Wrapper for the jOOQ Library

License

License

Categories

Categories

jOOQ Data Databases
GroupId

GroupId

org.ezlibs
ArtifactId

ArtifactId

ezjooq
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

EzjOOQ
Simple CRUD Repository Wrapper for the jOOQ Library
Project URL

Project URL

https://github.com/DanJSG/EzjOOQ
Source Code Management

Source Code Management

http://github.com/DanJSG/EzjOOQ/tree/master

Download ezjooq

How to add to project

<!-- https://jarcasting.com/artifacts/org.ezlibs/ezjooq/ -->
<dependency>
    <groupId>org.ezlibs</groupId>
    <artifactId>ezjooq</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.ezlibs/ezjooq/
implementation 'org.ezlibs:ezjooq:1.0.1'
// https://jarcasting.com/artifacts/org.ezlibs/ezjooq/
implementation ("org.ezlibs:ezjooq:1.0.1")
'org.ezlibs:ezjooq:jar:1.0.1'
<dependency org="org.ezlibs" name="ezjooq" rev="1.0.1">
  <artifact name="ezjooq" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.ezlibs', module='ezjooq', version='1.0.1')
)
libraryDependencies += "org.ezlibs" % "ezjooq" % "1.0.1"
[org.ezlibs/ezjooq "1.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.jooq : jooq jar 3.14.9
javax.persistence : javax.persistence-api jar 2.2

Project Modules

There are no modules declared in this project.

EzjOOQ (Easy jOOQ)
Test

Simple CRUD Repository Wrapper for the jOOQ Library utilising Java Persistence API annotations. Makes basic CRUD operations extremely simple, leaving regular jOOQ DSL queries for the complex stuff.

For more information on jOOQ, view their docs here.

This library is not officially associated with jOOQ in any way.

Installation with Maven

Add the following to the dependencies section of your pom.xml:

<dependency>
    <groupId>org.ezlibs</groupId>
    <artifactId>ezjooq</artifactId>
    <version>1.0.1</version>
</dependency>

This library also depends on jOOQ and the Java Persistence API, so ensure the following are also in your dependencies list:

<dependency>
    <groupId>org.jooq</groupId>
    <artifactId>jooq</artifactId>
    <version>3.14.9</version>
</dependency>
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>javax.persistence-api</artifactId>
    <version>2.2</version>
</dependency>

Versions 3.x.x of jOOQ should work with this library. Requires Java 8 or above.

Basic Usage

Annotating Your POJO Class

Annotate your classes with the @Table annotation and fields with the @Column annotation to let EzjOOQ know which table to use in your database. For example, a User class might look like:

@Table(name = "users")
public class User {

    @Column(name = "id")
    private int id;

    @Column(name = "email")
    private String email;

    @Column(name = "first_name")
    private String firstName;

    @Column(name = "last_name")
    private String lastName;

}

Creating a Repository Instance

To instantiate a repository for performing CRUD operations on the User class:

CrudRepository<User> repo = new PojoRepository<>(DSL.using(yourDataSource, SQLDialect.POSTGRES), User.class);

Storing Entities

To store a single User object:

User user = new User();
repo.create(user);

To store multiple User objects:

List<User> users = new ArrayList<>();
// ... add users to list ... 
repo.createMany(users);

Reading Entities

To read all users from the database:

List<User> users = repo.readAll();

To read all users from the database where a specific condition is met:

Condition condition = // jOOQ condition
List<User> users = repo.readAllWhere(condition);

To read one user from the database where a specific condition is met:

Condition condition = // jOOQ condition
User user = repo.readOneWhere(condition);

Updating Entities

To update a user in the database where a condition is met:

User user = new User();
Condition condition = // jOOQ condition
boolean success = repo.updateWhere(user, condition);

Deleting Entities

To delete a user from the database:

User user = new User();
boolean success = repo.delete(user);

License

This repository is available under the MIT License.

Versions

Version
1.0.1
1.0.0