spencercjh / jOOQ-Plus

Several simple classes to enhance JOOQ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jOOQ Plus

Several classes to enhance JOOQ and boost CRUD.

Background

Mybatis

Honestly, most Java programmers in China should have used Mybatis 3 and its enhanced libraries: Mybatis Plus or tk.mybatis.mapper . These two enhanced libraries provide a layer of encapsulation on top of mybatis, using proxies to provide single-table CRUD methods without maintaining the SQL templates (both in the form of Java annotations and XML form). Users only need to inherit the base class , complete the development of single-table CRUD (Create, Retrieve, Update, Delete and list, exists, count, etc.).

jOOQ

jOOQ and Mybatis are not essentially the same class of things: (Different use cases and the technical difference and between MyBatis and jOOQ, SQL Templating with jOOQ or MyBatis). I will not introduce the advantages and disadvantages of JOOQ here, nor will I say why you should use this and not use that. There is a lot of relevant information on the Internet.

Despite all the documentation and Lukas Eder(main maintainer of JOOQ community ) himself saying that JOOQ can work alone from the code generator, after practicing in several companies, this would give us an inch. Even a requirement like getting the self-incrementing ID of the inserted data would be difficult to satisfy. If you are interested in JOOQ, I highly recommend that you use jOOQ's code generator in conjunction with a database DDL maintenance tool such as Flyway so that you can use 100% of JOOQ's capabilities. I will show it in the test how to practice.

jOOQ Plus

Although no matter what library is used, CRUD Boy's job is still the same. We need to get CRUD done F A S T and focus on the actual business. When you use jOOQ, you will find:

  1. jOOQ's Dao lacks some necessary logic and is too simple. Dao also cannot return the incremental ID of the new data: jOOQ/jOOQ#13806. jOOQ's record has a CRUD-related API, but essentially the same as Dao: https://www.jooq.org/doc/latest/manual/sql-execution/crud-with-updatablerecords/simple-crud/.
  2. You need to maintain things from a bunch of SQL (whatever Java and Annotation or XML) to a bunch of Java fluent API code, but they're still the same CRUD code.

Essentially, we're just too lazy to maintain these code.You just have to write the code, you have to test them.It's tedious and boring.

Overview

jOOQ Plus is very very very simple. It is made up of a few interface and abstract implementation, designed to be similar to the Spring Data JPA CrudRepository(there it is: BaseCrudRepository) and PagingAndSortingRepository(traced by #5 and will be done recently).

In the implementation, I will make maximum use of Java generics and the code generated by the jOOQ code generator, rather than using proxies and reflection.

RoadMap

About

Several simple classes to enhance JOOQ

License:Apache License 2.0


Languages

Language:Java 100.0%