ColumnName cache now uses a map which supports multithreaded access.
The implementation now uses ConcurrentHashMap which provides faster multithreaded gets and safe writes.
This commit is contained in:
parent
999526c3c3
commit
2a15694fa1
|
@ -24,7 +24,7 @@
|
|||
package org.hibernate.engine.jdbc;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -35,11 +35,11 @@ import java.util.Map;
|
|||
public class ColumnNameCache {
|
||||
public static final float LOAD_FACTOR = .75f;
|
||||
|
||||
private final Map columnNameToIndexCache;
|
||||
private final Map<String, Integer> columnNameToIndexCache;
|
||||
|
||||
public ColumnNameCache(int columnCount) {
|
||||
// should *not* need to grow beyond the size of the total number of columns in the rs
|
||||
this.columnNameToIndexCache = new HashMap( columnCount + (int)( columnCount * LOAD_FACTOR ) + 1, LOAD_FACTOR );
|
||||
this.columnNameToIndexCache = new ConcurrentHashMap<String, Integer>( columnCount + (int)( columnCount * LOAD_FACTOR ) + 1, LOAD_FACTOR );
|
||||
}
|
||||
|
||||
public int getIndexForColumnName(String columnName, ResultSet rs) throws SQLException {
|
||||
|
@ -53,4 +53,4 @@ public class ColumnNameCache {
|
|||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue