HHH-8698 ColumnNameCache wraps and unwraps int to Integer multiple times

This commit is contained in:
Sanne Grinovero 2013-11-13 14:32:21 +00:00 committed by Steve Ebersole
parent 61a75accf5
commit e64376eb2b
2 changed files with 6 additions and 7 deletions

View File

@ -25,7 +25,6 @@ package org.hibernate.engine.jdbc;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
@ -33,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
*
* @author Steve Ebersole
*/
public class ColumnNameCache {
public final class ColumnNameCache {
private static final float LOAD_FACTOR = .75f;
private final ConcurrentHashMap<String, Integer> columnNameToIndexCache;
@ -61,13 +60,13 @@ public class ColumnNameCache {
*
* @throws SQLException INdicates a problems accessing the underlying JDBC ResultSet
*/
public int getIndexForColumnName(String columnName, ResultSet rs) throws SQLException {
public Integer getIndexForColumnName(String columnName, ResultSet rs) throws SQLException {
final Integer cached = columnNameToIndexCache.get( columnName );
if ( cached != null ) {
return cached;
}
else {
final int index = rs.findColumn( columnName );
final Integer index = Integer.valueOf( rs.findColumn( columnName ) );
columnNameToIndexCache.put( columnName, index);
return index;
}

View File

@ -96,7 +96,7 @@ public class ResultSetWrapperProxy implements InvocationHandler {
if ( isFirstArgColumnLabel( method, args ) ) {
try {
final int columnIndex = findColumn( (String) args[0] );
final Integer columnIndex = findColumn( (String) args[0] );
return invokeMethod(
locateCorrespondingColumnIndexMethod( method ),
buildColumnIndexMethodArgs( args, columnIndex )
@ -122,7 +122,7 @@ public class ResultSetWrapperProxy implements InvocationHandler {
* @return The column index corresponding to the given column name.
* @throws SQLException if the ResultSet object does not contain columnName or a database access error occurs
*/
private int findColumn(String columnName) throws SQLException {
private Integer findColumn(String columnName) throws SQLException {
return columnNameCache.getIndexForColumnName( columnName, rs );
}
@ -167,7 +167,7 @@ public class ResultSetWrapperProxy implements InvocationHandler {
return columnNameMethod.getDeclaringClass().getMethod( columnNameMethod.getName(), actualParameterTypes );
}
private Object[] buildColumnIndexMethodArgs(Object[] incomingArgs, int columnIndex) {
private Object[] buildColumnIndexMethodArgs(Object[] incomingArgs, Integer columnIndex) {
final Object[] actualArgs = new Object[incomingArgs.length];
actualArgs[0] = columnIndex;
System.arraycopy( incomingArgs, 1, actualArgs, 1, incomingArgs.length - 1 );