refer to correct openSession() method for Hibernate 4.0 (SPR-8776)

This commit is contained in:
Juergen Hoeller
2011-10-20 10:23:49 +00:00
parent de5a007e46
commit 0dfb617d8a
6 changed files with 48 additions and 5 deletions

View File

@@ -605,6 +605,28 @@ public abstract class ClassUtils {
return (getMethodIfAvailable(clazz, methodName, paramTypes) != null);
}
/**
* Determine whether the given class has a method with the given signature,
* and return it if available (else throws an <code>IllegalStateException</code>).
* <p>Essentially translates <code>NoSuchMethodException</code> to <code>IllegalStateException</code>.
* @param clazz the clazz to analyze
* @param methodName the name of the method
* @param paramTypes the parameter types of the method
* @return the method (never <code>null</code>)
* @throws IllegalStateException if the method has not been found
* @see java.lang.Class#getMethod
*/
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
try {
return clazz.getMethod(methodName, paramTypes);
}
catch (NoSuchMethodException ex) {
throw new IllegalStateException("Expected method not found: " + ex);
}
}
/**
* Determine whether the given class has a method with the given signature,
* and return it if available (else return <code>null</code>).