Bootiful SQL Template - simple SQL template engine for Spring Boot Application
A simple SQL template engine for Spring Boot applications.
Bootiful SQL Template is a simple wrapper of org.springframework.jdbc.core.JdbcTemplate
and org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
which offers following extension.
java.util.Map
and series of simple objectsLocalDate
, LocalTime
, LocalDateTime
, ZonedDateTime
and OffsetDateTime
.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>
@Configuration
public class ApplicationConfig {
@Bean
public SqlTemplate sqlTemplate(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
return new SqlTemplate(jdbcTemplate, namedParameterJdbcTemplate);
}
}
select * from emp
@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
}
}
T.B.D.