com.yesql4j:yesql4j-spring

to be added

License

License

GroupId

GroupId

com.yesql4j
ArtifactId

ArtifactId

yesql4j-spring
Last Version

Last Version

0.1.8-beta
Release Date

Release Date

Type

Type

jar
Description

Description

to be added
Source Code Management

Source Code Management

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

Download yesql4j-spring

How to add to project

<!-- https://jarcasting.com/artifacts/com.yesql4j/yesql4j-spring/ -->
<dependency>
    <groupId>com.yesql4j</groupId>
    <artifactId>yesql4j-spring</artifactId>
    <version>0.1.8-beta</version>
</dependency>
// https://jarcasting.com/artifacts/com.yesql4j/yesql4j-spring/
implementation 'com.yesql4j:yesql4j-spring:0.1.8-beta'
// https://jarcasting.com/artifacts/com.yesql4j/yesql4j-spring/
implementation ("com.yesql4j:yesql4j-spring:0.1.8-beta")
'com.yesql4j:yesql4j-spring:jar:0.1.8-beta'
<dependency org="com.yesql4j" name="yesql4j-spring" rev="0.1.8-beta">
  <artifact name="yesql4j-spring" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.yesql4j', module='yesql4j-spring', version='0.1.8-beta')
)
libraryDependencies += "com.yesql4j" % "yesql4j-spring" % "0.1.8-beta"
[com.yesql4j/yesql4j-spring "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

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.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