org.skife.jdbi.spring
Class DBIUtils

java.lang.Object
  extended by org.skife.jdbi.spring.DBIUtils

public class DBIUtils
extends java.lang.Object

Utility functions for use with spring transaction systems


Constructor Summary
DBIUtils()
           
 
Method Summary
static void closeHandleIfNecessary(Handle h, IDBI dbi)
          When used in conjuntion with Handle#getHandle() will only close the handle if it is not bound to an ongoing Spring transaction.
static Handle getHandle(IDBI dbi)
          Obtain a handle from dbi, using the transactionally bound one if there is one, otherwise a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBIUtils

public DBIUtils()
Method Detail

getHandle

public static Handle getHandle(IDBI dbi)
                        throws DBIException
Obtain a handle from dbi, using the transactionally bound one if there is one, otherwise a new one. If spring managed transactions are in effect than resources will be cleaned up by Spring, otherwise you are responsible for resource cleanup

Throws:
DBIException

closeHandleIfNecessary

public static void closeHandleIfNecessary(Handle h,
                                          IDBI dbi)
When used in conjuntion with Handle#getHandle() will only close the handle if it is not bound to an ongoing Spring transaction. If it is bound to a transaction then the Handle will be closed when the transaction completes and this will noop.

Parameters:
h - Handle to consider closing
dbi - DBI handle was obtained from