org.skife.jdbi.v2.sqlobject
Class SqlObjectBuilder

java.lang.Object
  extended by org.skife.jdbi.v2.sqlobject.SqlObjectBuilder

public class SqlObjectBuilder
extends Object

This duplicates the API on DBI and Handle for creating sql objects. While it is fine to use these methods to create sql objects, there is no real difference between them and the oones on DBI and Handle.


Constructor Summary
SqlObjectBuilder()
           
 
Method Summary
static
<T> T
attach(Handle handle, Class<T> sqlObjectType)
          Create a a sql object of the specified type bound to this handle.
static void close(Object sqlObject)
          Used to close a sql object which lacks a close() method.
static
<T> T
onDemand(DBI dbi, Class<T> sqlObjectType)
          Create a new sql object which will obtain and release connections from this dbi instance, as it needs to, and can, respectively.
static
<T> T
open(DBI dbi, Class<T> sqlObjectType)
          Open a handle and attach a new sql object of the specified type to that handle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlObjectBuilder

public SqlObjectBuilder()
Method Detail

attach

public static <T> T attach(Handle handle,
                           Class<T> sqlObjectType)
Create a a sql object of the specified type bound to this handle. Any state changes to the handle, or the sql object, such as transaction status, closing it, etc, will apply to both the object and the handle.

Parameters:
handle - the Handle instance to attach ths sql object to
sqlObjectType - the type of sql object to create
Returns:
the new sql object bound to this handle

close

public static void close(Object sqlObject)
Used to close a sql object which lacks a close() method.

Parameters:
sqlObject - the sql object to close

onDemand

public static <T> T onDemand(DBI dbi,
                             Class<T> sqlObjectType)
Create a new sql object which will obtain and release connections from this dbi instance, as it needs to, and can, respectively. You should not explicitely close this sql object

Parameters:
dbi - the DBI instance to be used for obtaining connections when they are required
sqlObjectType - an interface with annotations declaring desired behavior
Returns:
a new sql object of the specified type, with a dedicated handle

open

public static <T> T open(DBI dbi,
                         Class<T> sqlObjectType)
Open a handle and attach a new sql object of the specified type to that handle. Be sure to close the sql object (via a close() method, or calling IDBI.close(Object)

Parameters:
dbi - the dbi to be used for opening the underlying handle
sqlObjectType - an interface with annotations declaring desired behavior
Returns:
a new sql object of the specified type, with a dedicated handle


Copyright © 2011. All Rights Reserved.