mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-10 13:14:50 +00:00
HHH-8939 Reduce contention on initialization of ColumnNameCache instances by loaders
This commit is contained in:
parent
09ea1b33f9
commit
0c5c980790
@ -2101,15 +2101,17 @@ private ResultSet wrapResultSetIfEnabled(final ResultSet rs, final SessionImplem
|
||||
}
|
||||
|
||||
private ColumnNameCache retreiveColumnNameToIndexCache(final ResultSet rs) throws SQLException {
|
||||
if ( columnNameCache == null ) {
|
||||
synchronized ( this ) {
|
||||
if ( columnNameCache == null ) {
|
||||
LOG.trace( "Building columnName -> columnIndex cache" );
|
||||
columnNameCache = new ColumnNameCache( rs.getMetaData().getColumnCount() );
|
||||
}
|
||||
}
|
||||
final ColumnNameCache cache = columnNameCache;
|
||||
if ( cache == 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" );
|
||||
columnNameCache = new ColumnNameCache( rs.getMetaData().getColumnCount() );
|
||||
return columnNameCache;
|
||||
}
|
||||
else {
|
||||
return cache;
|
||||
}
|
||||
return columnNameCache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user