| I think the correct solution is to make an addition to hibernate-core\src\main\java\org\hibernate\internal\util\ReflectHelper.java
private static final Map<Object[], Method> METHOD_CACHE = new ConcurrentReferenceHashMap<>(
10,
ConcurrentReferenceHashMap.ReferenceType.SOFT,
ConcurrentReferenceHashMap.ReferenceType.SOFT
);
public static Method getMethod(Class clazz, String methodName, Class[] parameterTypes) throws NoSuchMethodException {
final Object[] key = new Object[] { clazz, methodName, parameterTypes };
Method value = METHOD_CACHE.get( key );
if ( value == null ) {
value = clazz.getMethod( methodName, parameterTypes );
METHOD_CACHE.put( key, value );
}
return value;
}
(which is based on code in hibernate-envers\src\main\java\org\hibernate\envers\internal\tools\ReflectionTools.java), and then change the problem line in org.hibernate.engine.jdbc.ResultSetWrapperProxy.locateCorrespondingColumnIndexMethod(Method) to:
return ReflectHelper.getMethod( columnNameMethod.getDeclaringClass(), columnNameMethod.getName(),
actualParameterTypes );
(Other uses of java.lang.Class.getMethod(String, Class[]) elsewhere in the codebase could also use this if they are likely to often repeat the same searcfh and thus benefit from caching.) |