com.yesql4j:yesql4j-reactor

to be added

License

License

Categories

Categories

React User Interface Web Frameworks Reactor Container Microservices Reactive libraries
GroupId

GroupId

com.yesql4j
ArtifactId

ArtifactId

yesql4j-reactor
Last Version

Last Version

0.1.1-beta
Release Date

Release Date

Type

Type

jar
Description

Description

to be added

Download yesql4j-reactor

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
io.vertx : vertx-mysql-client jar 3.8.5
io.projectreactor : reactor-core jar 3.3.3.RELEASE
javax.validation : validation-api jar 2.0.1.Final
org.slf4j : slf4j-api jar 1.7.30

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.6.0
ch.qos.logback : logback-classic jar 1.2.3
io.projectreactor : reactor-test jar 3.3.3.RELEASE

Project Modules

There are no modules declared in this project.

Yesql4j

Maven plugin for Java code generation from sql files. Currently supported frameworks:

  • Spring (jdbc template)
  • Vert.x MySQL + reactor

Inspired by https://github.com/krisajenkins/yesql

Installation

<plugin>
    <groupId>com.yesql4j</groupId>
    <artifactId>yesql4j-maven-plugin</artifactId>
    <version>0.1.8-beta</version>
    <configuration>
        <generator>SPRING</generator>
    </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Writing sql files

SQL files should be placed under src/main/sql. Example sql file (src/main/sql/com/example/queries.sql):

-- name: ddl!
CREATE TABLE example_table (
    id bigint unsigned auto_increment primary key,
    name varchar(255),
    stamp timestamp default now(),
    value_decimal decimal(12, 2),
    value_double double,
    value_bytes blob
);

-- name: create-entry<!
INSERT INTO example_table (name, stamp, value_decimal, value_double, value_bytes) VALUES (?, ?, ?, ?, ?);

-- name: update-entry!
-- @param String name
-- @param Long   id
UPDATE example_table SET name = :name WHERE id = :id;

-- name: select-entries
SELECT * FROM example_table;

-- name: select-entry
-- @param Long id
SELECT * FROM example_table WHERE id = :id;

Base folder for sql files can be changed using sqlSourceRoot configuration option (default "${basedir}/src/main/sql")

These files will be translated to java classes, placed in ${project.build.directory}/generated-sources/sql/java (javaOutputDirectory configuration option)

Naming conventions

  • Use ! postfix for update queries (example: -- name: update-entry!).
  • Use <! postfix for returning generated key (example: -- name: create-entry<!)
  • All other cases will return rows from database.

Parameters

  • You can use both named (like :prop) and ? parameters.
  • Param types can be specified in comment: -- @param Type name. Base java types from java.lang, java.util and java.math can be specified without package, full class name with package required otherwise.

Spring usage

TO BE ADDED

Reactor + Vert.x MySQL

TO BE ADDED

Versions

Version
0.1.1-beta
0.1-beta