Compatibility improvement suggestion for org.hibernate.engine.jdbc.internal.ResultSetReturnImpl

Description

The fix implemented for issue in org.hibernate.engine.jdbc.internal.ResultSetReturnImpl performs an instanceof check on the statement object to determine if the current statement is an instance of CallableStatement. This presents a potential problem if a framework wraps a statement object in either a proxy or a concrete class that implements both PreparedStatement and CallableStatement.

This can result in wrapped/proxied PreparedStatement objects being incorrectly identified as CallableStatement instances with the end result often being a ClassCastException, AbstractMethodError, or NoSuchMethodException error in the wrapper or proxy.

Since JDK 6 is now a minimum requirement it seems like a more compatible fix would have been to call java.sql.Wrapper.isWrapperFor(CallableStatement.class) method on the statement object to determine the instance type instead of using the instanceof keyword. While I'm not stating that the implemented fix is technically wrong, I believe the use of Wrapper.isWrapperFor would promote improved compatibility across the greatest range of pooling frameworks, JDBC drivers, etc.

Improvement Suggestion:

org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.java

Environment

Hibernate Core 4.3.5, Oracle 11g

Activity

Show:
Gail Badner
July 10, 2014, 5:58 AM

Closing resolved issued in preparation for releasing 4.3.6.

Brett Meyer
May 23, 2014, 9:50 PM

Thanks again!

Joel Bagley
April 25, 2014, 2:54 PM
Brett Meyer
April 25, 2014, 2:44 PM

, great catch. Interested in giving that a shot through a pull request?

Fixed

Assignee

Brett Meyer

Reporter

Joel Bagley

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Minor