| Interface | Description |
|---|---|
| Binder<A extends Annotation,T> | |
| BinderFactory<BindAnnotationType extends Annotation,BoundObjectType> |
Factor for building
Binder instances. |
| SqlObjectConfigurerFactory |
Generates
Consumer<SqlObjectConfig> instances to satisfy the contract of a
SqlObjectConfiguringAnnotation-annotated annotation. |
| SqlStatementCustomizer |
Used with
SqlStatementCustomizerFactory to
customize sql statements via annotations |
| SqlStatementCustomizerFactory |
Interface used in conjunction with
SqlStatementCustomizingAnnotation to generate
SqlStatementCustomizer instances. |
| TransactionalCallback<R,T extends Transactional<T>,X extends Exception> | |
| TransactionalConsumer<T extends Transactional<T>,X extends Exception> |
| Class | Description |
|---|---|
| CreateSqlObject.Factory | |
| SqlAnnotations | |
| SqlBatch.Factory | |
| SqlCall.Factory | |
| SqlObjectConfig |
Configuration class for the SqlObject plugin.
|
| SqlObjectPlugin | |
| SqlQuery.Factory | |
| SqlUpdate.Factory | |
| Transaction.Decorator |
| Enum | Description |
|---|---|
| SqlObjectFactory |
| Annotation Type | Description |
|---|---|
| Bind |
A binding annotation.
|
| BindBean | |
| BindingAnnotation |
Annotation used to mark binding annotations.
|
| BindMap |
Bind a
Map<String, Object> |
| CreateSqlObject |
Use this annotation on a sql object method to create a new sql object with the same underlying handle as the sql
object the method is invoked on.
|
| GetGeneratedKeys | |
| SqlBatch |
Annotate a method to indicate that it will create and execute a SQL batch.
|
| SqlCall |
Support for stored proc invocation.
|
| SqlObjectConfiguringAnnotation |
Annotation used to configure
SqlObjectConfig. |
| SqlQuery |
Used to indicate that a method should execute a query.
|
| SqlStatementCustomizingAnnotation |
Annotation used to build customizing annotations.
|
| SqlUpdate |
Used to indicate that a method should execute a non-query sql statement
|
| Transaction |
Causes the annotated method to be run in a transaction.
|
The sql objects API allows for declarative definition of interfaces which will handle the generation of sql statements and queries on your behalf when needed. Take the following interface:
public interface TheBasics
{
@SqlUpdate("insert into something (id, name) values (:id, :name)")
int insert(@BindBean Something something);
@SqlQuery("select id, name from something where id = :id")
Something findById(@Bind("id") long id);
}
You obtain an instance of TheBasics via one of three means, the first opens a new
handle against a DBI instance, the second attaches the object to an already open handle, and the third
will obtain and release connections on demand against a DBI instance.
DBI dbi = new DBI(dataSource);
Handle handle = dbi.open();
TheBasics via_open = dbi.open(TheBasics.class);
TheBasics attached = handle.attach(TheBasics.class);
TheBasics on_demand = dbi.onDemand(TheBasics.class);
It is important to ensure you close the underlying handle on a sql object if it was opened via the DBI#open in particular.
A number of mixin interfaces are included in the org.skife.jdbi.v2.sqlobject package. These provide additional functionality on your sql object, such as transactions or access to the underlying Handle instance. To make use of them just have your sql object interface extend the mixin interface.
Copyright © 2016. All rights reserved.