HHH-15139 - Improvements for QueryInterpretationCache

- improvements to SqmInterpretationsKey
- improvements to AbstractFetchParent
This commit is contained in:
Steve Ebersole 2022-03-25 07:16:15 -05:00
parent 6fd8034ec5
commit 33a7133695
2 changed files with 14 additions and 13 deletions

View File

@ -73,12 +73,7 @@ public class SelectInterpretationsKey implements QueryInterpretationCache.Key {
}
private int generateHashCode() {
int result = sql.hashCode();
result = 31 * result + jdbcValuesMappingProducer.hashCode();
result = 31 * result + ( querySpaces != null ? querySpaces.hashCode() : 0 );
result = 31 * result + ( tupleTransformer != null ? tupleTransformer.hashCode() : 0 );
result = 31 * result + ( resultListTransformer != null ? resultListTransformer.hashCode() : 0 );
return result;
return sql.hashCode();
}
@Override

View File

@ -9,6 +9,7 @@ package org.hibernate.sql.results.graph;
import java.util.Collections;
import java.util.List;
import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.spi.NavigablePath;
import org.hibernate.type.descriptor.java.JavaType;
@ -57,15 +58,20 @@ public abstract class AbstractFetchParent implements FetchParent {
@Override
public Fetch findFetch(Fetchable fetchable) {
if ( fetches != null ) {
for ( Fetch fetch : fetches ) {
final Fetchable fetchedMapping = fetch.getFetchedMapping();
if ( fetchedMapping != null
&& fetchedMapping.getNavigableRole().equals( fetchable.getNavigableRole() ) ) {
return fetch;
}
if ( fetches == null ) {
return null;
}
for ( int i = 0; i < fetches.size(); i++ ) {
final Fetch fetch = fetches.get( i );
final Fetchable fetchedMapping = fetch.getFetchedMapping();
if ( fetchedMapping == fetchable
// the fetched mapping for the version is a Basic attribute, so check the role
|| ( fetchable instanceof EntityVersionMapping && fetchable.getNavigableRole().equals( fetchedMapping.getNavigableRole() ) ) ) {
return fetch;
}
}
return null;
}
}