HHH-8698 ColumnNameCache wraps and unwraps int to Integer multiple times
This commit is contained in:
parent
61a75accf5
commit
e64376eb2b
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue