Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zero88/jooqx

Vert.x jOOQ DSL
https://github.com/zero88/jooqx

dsl jooq rql vertx

Last synced: 26 days ago
JSON representation

Vert.x jOOQ DSL

Awesome Lists containing this project

README

        

= jOOQ.x - Vertx jOOQ DSL
zero88

image:https://github.com/zero88/jooqx/actions/workflows/jooqx.yml/badge.svg[jooqx,link=https://github.com/zero88/jooqx/actions/workflows/jooqx.yml]
image:https://img.shields.io/github/v/release/zero88/jooqx?sort=semver[GitHub release (latest SemVer)]
image:https://img.shields.io/nexus/r/io.github.zero88/jooqx?server=https%3A%2F%2Foss.sonatype.org[Sonatype Nexus (Releases)]
image:https://img.shields.io/nexus/s/io.github.zero88/jooqx?server=https%3A%2F%2Foss.sonatype.org[Sonatype Nexus (Snapshots)]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=ncloc[Lines of Code,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=coverage[Coverage,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=sqale_rating[Maintainability Rating,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=reliability_rating[Reliability Rating,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=security_rating[Security Rating,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]
image:https://sonarcloud.io/api/project_badges/measure?project=zero88_jooqx&metric=alert_status[Quality Gate Status,link=https://sonarcloud.io/dashboard?id=zero88_jooqx]

`jooqx` leverages the power of typesafe SQL from https://www.jooq.org[jOOQ DSL] and uses the reactive and non-blocking `SQL driver` from https://vertx.io/docs/#databases[Vert.x]

== Examples

[source,java,subs="attributes,verbatim"]
----
// Vertx part: Init Postgres client
PgConnectOptions connectOptions = new PgConnectOptions() <1>
.setPort(5432)
.setHost("the-host")
.setDatabase("the-db")
.setUser("user")
.setPassword("secret");
PoolOptions poolOptions = new PoolOptions().setMaxSize(5); <2>
PgPool pgPool = PgPool.pool(connectOptions, poolOptions); <3>

// jOOQ part: Init DSL context
DSLContext dsl = DSL.using(new DefaultConfiguration().set(SQLDialect.POSTGRES)); <4>
Authors table = Tables.AUTHORS; <5>

// jooqx part: Enjoy moment
Jooqx jooqx = Jooqx.builder().setVertx(vertx).setDSL(dsl).setSqlClient(pgPool).build(); <6>
jooqx.execute(
dsl -> dsl.select().from(table).where(table.COUNTRY.eq("VN"), <7>
DSLAdapter.fetchOne(table, Collections.singletonList(table.ID, table.NAME), <8>
ar -> System.out.println(ar.result()) <9>
);
//+----+-----------+
//| id|name |
//+----+-----------+
//| *88|*zero |
//+----+-----------+
----
<1> Create `Vertx` PostgreSQL connection options
<2> Create `Vertx` SQL pool options
<3> Init `Vertx` https://vertx.io/docs/vertx-pg-client/java/[PostgreSQL pool client]
<4> Init `jOOQ` DSL context with `Postgres` dialect
<5> The example table is generated by `jOOQ` https://www.jooq.org/doc/latest/manual/getting-started/tutorials/jooq-in-7-steps/jooq-in-7-steps-step3/[codegen]
<6> Init `jooqx` instance by builder
<7> First arg: The https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html[function] produces `jOOQ` https://www.jooq.org/doc/latest/manual/getting-started/tutorials/jooq-in-7-steps/jooq-in-7-steps-step5/[Query] by DSL context
<8> Second arg: the jooqx https://zero88.github.io/jooqx/jooqx/main/features-result-adapter.html[result adapter] to convert `Vertx` SQL result to typesafe record in `jOOQ`
<9> Third arg: just simple async future handler

Interesting?
Please check out https://zero88.github.io/jooqx/[documentation]