com.googlecode.genericdao.dao
Class DAOUtil

java.lang.Object
  extended by com.googlecode.genericdao.dao.DAOUtil

public class DAOUtil
extends Object

Utility methods for Hibernate Genereic DAO.

Author:
dwolverton

Constructor Summary
DAOUtil()
           
 
Method Summary
static Object callMethod(Object object, String methodName, Class<?>[] paramTypes, Object... args)
          This is a helper method to call a method on an Object with the given parameters.
static Object callMethod(Object object, String methodName, Object... args)
          This is a helper method to call a method on an Object with the given parameters.
static Method getMethod(Class<?> klass, String methodName, Class<?>... paramTypes)
           
static
<T> List<Class<?>>
getTypeArguments(Class<T> baseClass, Class<? extends T> childClass)
          Get the actual type arguments a child class has used to extend a generic base class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DAOUtil

public DAOUtil()
Method Detail

getTypeArguments

public static <T> List<Class<?>> getTypeArguments(Class<T> baseClass,
                                                  Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a generic base class. (Taken from http://www.artima.com/weblogs/viewpost.jsp?thread=208860. Thanks mathieu.grenonville for finding this solution!)

Parameters:
baseClass - the base class
childClass - the child class
Returns:
a list of the raw classes for the actual type arguments.

callMethod

public static Object callMethod(Object object,
                                String methodName,
                                Object... args)
                         throws NoSuchMethodException,
                                IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
This is a helper method to call a method on an Object with the given parameters. It is used for dispatching to specific DAOs that do not implement the GenericDAO interface.

Throws:
NoSuchMethodException
IllegalArgumentException
IllegalAccessException
InvocationTargetException

callMethod

public static Object callMethod(Object object,
                                String methodName,
                                Class<?>[] paramTypes,
                                Object... args)
                         throws NoSuchMethodException,
                                IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
This is a helper method to call a method on an Object with the given parameters. It is used for dispatching to specific DAOs that do not implement the GenericDAO interface.

Throws:
NoSuchMethodException
IllegalArgumentException
IllegalAccessException
InvocationTargetException

getMethod

public static Method getMethod(Class<?> klass,
                               String methodName,
                               Class<?>... paramTypes)


Copyright © 2008-2011. All Rights Reserved.