com.yesql4j:yesqlj4-root

to be added

License

License

GroupId

GroupId

com.yesql4j
ArtifactId

ArtifactId

yesqlj4-root
Last Version

Last Version

0.1.8-beta
Release Date

Release Date

Type

Type

pom
Description

Description

com.yesql4j:yesqlj4-root
to be added
Project URL

Project URL

https://yesql4j.com/
Source Code Management

Source Code Management

https://github.com/batsuev/yesql4j/tree/master

Download yesqlj4-root

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • yesql4j-vertx-mysql-reactor
  • yesql4j-maven-plugin
  • yesql4j-spring

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.8-beta
0.1.7-beta
0.1.6-beta
0.1.5-beta
0.1.4-beta
0.1.3-beta
0.1.2-beta
0.1.1-beta
0.1-beta