org.springframework.dao.support
Class DataAccessUtils

java.lang.Object
  extended byorg.springframework.dao.support.DataAccessUtils

public abstract class DataAccessUtils
extends Object

Miscellaneous utility methods for DAO implementations. Useful with any data access technology.

Since:
1.0.2
Author:
Juergen Hoeller

Constructor Summary
DataAccessUtils()
           
 
Method Summary
static int intResult(Collection results)
          Return a unique int result from the given Collection.
static long longResult(Collection results)
          Return a unique long result from the given Collection.
static Object objectResult(Collection results, Class requiredType)
          Return a unique result object from the given Collection.
static Object requiredUniqueResult(Collection results)
          Return a unique result object from the given Collection.
static Object uniqueResult(Collection results)
          Return a unique result object from the given Collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataAccessUtils

public DataAccessUtils()
Method Detail

uniqueResult

public static Object uniqueResult(Collection results)
                           throws IncorrectResultSizeDataAccessException
Return a unique result object from the given Collection. Returns null if 0 result objects found; throws an exception if more than 1 found.

Parameters:
results - the result Collection
Returns:
the unique result object, or null if none
Throws:
IncorrectResultSizeDataAccessException - if more than one result object has been found in the given Collection

requiredUniqueResult

public static Object requiredUniqueResult(Collection results)
                                   throws IncorrectResultSizeDataAccessException
Return a unique result object from the given Collection. Throws an exception if 0 or more than 1 result objects found.

Parameters:
results - the result Collection
Returns:
the unique result object
Throws:
IncorrectResultSizeDataAccessException - if more than one result object or none at all has been found in the given Collection

objectResult

public static Object objectResult(Collection results,
                                  Class requiredType)
                           throws IncorrectResultSizeDataAccessException,
                                  TypeMismatchDataAccessException
Return a unique result object from the given Collection. Throws an exception if 0 or more than 1 result objects found, of if the unique result object is not convertable to the specified required type.

Parameters:
results - the result Collection
Returns:
the unique result object
Throws:
IncorrectResultSizeDataAccessException - if more than one result object or none at all has been found in the given Collection
TypeMismatchDataAccessException - if the unique object does not match the specified required type

intResult

public static int intResult(Collection results)
                     throws IncorrectResultSizeDataAccessException,
                            TypeMismatchDataAccessException
Return a unique int result from the given Collection. Throws an exception if 0 or more than 1 result objects found, of if the unique result object is not convertable to an int.

Parameters:
results - the result Collection
Returns:
the unique int result
Throws:
IncorrectResultSizeDataAccessException - if more than one result object or none at all has been found in the given Collection
TypeMismatchDataAccessException - if the unique object in the collection is not convertable to an int

longResult

public static long longResult(Collection results)
                       throws IncorrectResultSizeDataAccessException,
                              TypeMismatchDataAccessException
Return a unique long result from the given Collection. Throws an exception if 0 or more than 1 result objects found, of if the unique result object is not convertable to a long.

Parameters:
results - the result Collection
Returns:
the unique long result
Throws:
IncorrectResultSizeDataAccessException - if more than one result object or none at all has been found in the given Collection
TypeMismatchDataAccessException - if the unique object in the collection is not convertable to a long


Copyright (C) 2003-2004 The Spring Framework Project.