HHH-13496 Refactor entrySet iterators

This commit is contained in:
Sanne Grinovero 2019-07-05 16:34:17 +01:00
parent cdcd6bfe76
commit 9c19bbd611
3 changed files with 24 additions and 14 deletions

View File

@ -2130,8 +2130,9 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
return;
}
for ( Table table : jpaIndexHoldersByTable.keySet() ) {
final List<JPAIndexHolder> jpaIndexHolders = jpaIndexHoldersByTable.get( table );
for ( Map.Entry<Table, List<JPAIndexHolder>> entry : jpaIndexHoldersByTable.entrySet() ) {
final Table table = entry.getKey();
final List<JPAIndexHolder> jpaIndexHolders = entry.getValue();
for ( JPAIndexHolder holder : jpaIndexHolders ) {
buildUniqueKeyFromColumnNames(
table,

View File

@ -2239,12 +2239,17 @@ public abstract class Loader {
return result;
}
for ( String name : namedParams.keySet() ) {
TypedValue typedValue = namedParams.get( name );
int columnSpan = typedValue.getType().getColumnSpan( getFactory() );
int[] locs = getNamedParameterLocs( name );
final boolean debugEnabled = LOG.isDebugEnabled();
final SessionFactoryImplementor factory = getFactory();
for ( Map.Entry<String, TypedValue> entry : namedParams.entrySet() ) {
final String name = entry.getKey();
final TypedValue typedValue = entry.getValue();
final Type type = typedValue.getType();
final int columnSpan = type.getColumnSpan( factory );
final int[] locs = getNamedParameterLocs( name );
for ( int loc : locs ) {
if ( LOG.isDebugEnabled() ) {
if ( debugEnabled ) {
LOG.debugf(
"bindNamedParameters() %s -> %s [%s]",
typedValue.getValue(),
@ -2253,7 +2258,7 @@ public abstract class Loader {
);
}
int start = loc * columnSpan + startIndex;
typedValue.getType().nullSafeSet( statement, typedValue.getValue(), start, session );
type.nullSafeSet( statement, typedValue.getValue(), start, session );
}
result += locs.length;
}

View File

@ -230,8 +230,9 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
criteriaInfoMap.put( rootCriteria, rootProvider);
nameCriteriaInfoMap.put( rootProvider.getName(), rootProvider );
for ( final String key : associationPathCriteriaMap.keySet() ) {
final Criteria value = associationPathCriteriaMap.get( key );
for ( Map.Entry<String, Criteria> entry : associationPathCriteriaMap.entrySet() ) {
final String key = entry.getKey();
final Criteria value = entry.getValue();
final CriteriaInfoProvider info = getPathInfo( key );
criteriaInfoMap.put( value, info );
nameCriteriaInfoMap.put( info.getName(), info );
@ -294,8 +295,9 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
private void createCriteriaSQLAliasMap() {
int i = 0;
for(final Criteria crit : criteriaInfoMap.keySet()){
final CriteriaInfoProvider value = criteriaInfoMap.get( crit );
for ( Map.Entry<Criteria, CriteriaInfoProvider> entry : criteriaInfoMap.entrySet() ) {
final Criteria crit = entry.getKey();
final CriteriaInfoProvider value = entry.getValue();
String alias = crit.getAlias();
if ( alias == null ) {
// the entity name
@ -320,9 +322,11 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
final LockOptions lockOptions = new LockOptions();
final Map<String, LockMode> lockModeMap = rootCriteria.getLockModes();
for ( final String key : lockModeMap.keySet() ) {
for ( Map.Entry<String, LockMode> entry : lockModeMap.entrySet() ) {
final String key = entry.getKey();
final LockMode value = entry.getValue();
final Criteria subcriteria = getAliasedCriteria( key );
lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lockModeMap.get( key ) );
lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), value );
}
final List<Object> values = new ArrayList<Object>();