HHH-8939 Reduce contention on initialization of ColumnNameCache instances by loaders
This commit is contained in:
parent
758d635ca2
commit
0f0a95e2b8
|
@ -2104,16 +2104,18 @@ public abstract class Loader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ColumnNameCache retreiveColumnNameToIndexCache(final ResultSet rs) throws SQLException {
|
private ColumnNameCache retreiveColumnNameToIndexCache(final ResultSet rs) throws SQLException {
|
||||||
if ( columnNameCache == null ) {
|
final ColumnNameCache cache = columnNameCache;
|
||||||
synchronized ( this ) {
|
if ( cache == null ) {
|
||||||
if ( columnNameCache == null ) {
|
//there is no need for a synchronized second check, as in worst case
|
||||||
|
//we'll have allocated an unnecessary ColumnNameCache
|
||||||
LOG.trace( "Building columnName -> columnIndex cache" );
|
LOG.trace( "Building columnName -> columnIndex cache" );
|
||||||
columnNameCache = new ColumnNameCache( rs.getMetaData().getColumnCount() );
|
columnNameCache = new ColumnNameCache( rs.getMetaData().getColumnCount() );
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return columnNameCache;
|
return columnNameCache;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by subclasses that load entities
|
* Called by subclasses that load entities
|
||||||
|
|
Loading…
Reference in New Issue