Skip to content

Integration overview

Kaumei JDBC keeps runtime integration simple. Generated classes operate on a plain JDBC connection provided through a single interface.

JdbcConnectionProvider.java
@FunctionalInterface
public interface JdbcConnectionProvider {
Connection getConnection() throws SQLException;
}

The Spring example below shows the structure of a JDBC service interface:

NamesServiceKaumei.java
@JdbcGeneration(
classAnnotations = {Transactional.class, Service.class},
constructorAnnotations = {Autowired.class}
)
public interface NamesServiceKaumei extends NamesService {
@JdbcUpdate("DELETE FROM value_budge")
int deleteAll();
@JdbcUpdate("DELETE FROM value_budge where value_name = :value")
int delete(String value);
@JdbcUpdate("INSERT INTO value_budge (value_name, budge) VALUES (:value, :budge)")
void insert(String value, @Nullable Integer budge);
@JdbcSelect("SELECT count(*) FROM value_budge")
int count();
@JdbcSelect("SELECT * FROM value_budge order by value_name, budge")
List<ValueBudge> selectAll();
}

Each generated class exposes a constructor that accepts a JdbcConnectionProvider. Every DAO method borrows the current connection from that provider. The generated implementation contract is defined in Specification Overview.

Provide an implementation that fits your framework. Wire it into your dependency injection container. These guides walk through common scenarios: