I was using the YourKit Java profiler to investigate some performance issues in our code when doing a series of Hibernate generate read queries form our code (most of the queries are 8-16kb of SQL, and return one or two rows but dozens and dozens of colums). Under this load, of all the time being spent by Hibernate, roughly 20% of it was coming from a single stack trace:
sun.reflect.Reflection.getCallerClass() called from
Class.java: line1783
java.lang.Class.getMethod(String, Class[]) called from
ResultSetWrapperProxy.java: line 137 org.hibernate.engine.jdbc.ResultSetWrapperProxy.locateCorrespondingColumnIndexMethod(Method) called from
ResultSetWrapperProxy.java: line 71
org.hibernate.engine.jdbc.ResultSetWrapperProxy.invoke(Object, Method, Object[])
The basic issue here is that ResultSetWrapperProxy.locateCorrespondingColumnIndexMethod(Method) is called often, it's using Java reflection which is slow, and it's not caching the results despite the fact it often repeats. |