bootiful-sqltemplate-core

Bootiful SQL Template Core

License

License

Categories

Categories

Ninja User Interface Web Frameworks
GroupId

GroupId

ninja.cero.bootiful-sqltemplate
ArtifactId

ArtifactId

bootiful-sqltemplate-core
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

bootiful-sqltemplate-core
Bootiful SQL Template Core
Project URL

Project URL

https://github.com/cero-t/sqltemplate
Source Code Management

Source Code Management

https://github.com/cero-t/sqltemplate

Download bootiful-sqltemplate-core

How to add to project

<!-- https://jarcasting.com/artifacts/ninja.cero.bootiful-sqltemplate/bootiful-sqltemplate-core/ -->
<dependency>
    <groupId>ninja.cero.bootiful-sqltemplate</groupId>
    <artifactId>bootiful-sqltemplate-core</artifactId>
    <version>1.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/ninja.cero.bootiful-sqltemplate/bootiful-sqltemplate-core/
implementation 'ninja.cero.bootiful-sqltemplate:bootiful-sqltemplate-core:1.0.4'
// https://jarcasting.com/artifacts/ninja.cero.bootiful-sqltemplate/bootiful-sqltemplate-core/
implementation ("ninja.cero.bootiful-sqltemplate:bootiful-sqltemplate-core:1.0.4")
'ninja.cero.bootiful-sqltemplate:bootiful-sqltemplate-core:jar:1.0.4'
<dependency org="ninja.cero.bootiful-sqltemplate" name="bootiful-sqltemplate-core" rev="1.0.4">
  <artifact name="bootiful-sqltemplate-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='ninja.cero.bootiful-sqltemplate', module='bootiful-sqltemplate-core', version='1.0.4')
)
libraryDependencies += "ninja.cero.bootiful-sqltemplate" % "bootiful-sqltemplate-core" % "1.0.4"
[ninja.cero.bootiful-sqltemplate/bootiful-sqltemplate-core "1.0.4"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework : spring-jdbc jar 4.1.7.RELEASE
org.slf4j : slf4j-api jar 1.7.12
org.freemarker : freemarker jar 2.3.21

test (5)

Group / Artifact Type Version
org.springframework : spring-test jar 4.1.7.RELEASE
org.springframework : spring-context jar 4.1.7.RELEASE
junit : junit jar 4.12
com.h2database : h2 jar 1.4.187
mysql : mysql-connector-java jar 5.1.34

Project Modules

There are no modules declared in this project.

Bootiful SQL Template

A simple SQL template engine for Spring Boot applications.

What is Bootiful SQL Template?

Bootiful SQL Template is a simple wrapper of org.springframework.jdbc.core.JdbcTemplate and org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate which offers following extension.

  • fluent API
  • reading SQL template file (plain SQL files or FreeMarker template files)
  • binding to/from value object and java.util.Map and series of simple objects
  • binding to/from public fields of value object besides private fields with accessor methods
  • supports JSR-310 time types such as LocalDate, LocalTime, LocalDateTime, ZonedDateTime and OffsetDateTime.
  • supports time zones

Getting started

  • Add dependency in your pom.xml or other build tool's configuration file.
<dependencies>
    <dependency>
        <groupId>ninja.cero.bootiful-sqltemplate</groupId>
        <artifactId>bootiful-sqltemplate</artifactId>
        <version>2.0.0</version>
    </dependency>
    ...
</dependencies>
  • Create application class or configuration class of your Spring Boot application as follows.
@Configuration
public class ApplicationConfig {
	@Bean
	public SqlTemplate sqlTemplate(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
		return new SqlTemplate(jdbcTemplate, namedParameterJdbcTemplate);
	}
}
  • Create an SQL file in the classpath. (cf. src/main/resources/sql/selectAll.sql)
select * from emp
  • Create a data access class having SqlTemplate bean as an @Autowired property. Then the data access method can call the forObject / forList / update / query methods of the SqlTemplate class.
@Service
public class SampleProcess {
    @Autowired
    protected SqlTemplate template;

    public void process() {
        List<Emp> emps = template.forList("sql/selectAll.sql", Emp.class);
        emps.forEach(e -> System.out.println(e.ename)); // SMITH ... MILLER
    }
}

Functions

T.B.D.

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0