HHH-13476 Micro-optimisations of TwoPhaseLoad#getOverridingEager
This commit is contained in:
parent
e46287438b
commit
e532820240
|
@ -208,7 +208,7 @@ public final class TwoPhaseLoad {
|
|||
// HHH-10989: We need to resolve the collection so that a CollectionReference is added to StatefulPersistentContext.
|
||||
// As mentioned above, hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
// so do not assign the resolved, unitialized PersistentCollection back to hydratedState[i].
|
||||
Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i] );
|
||||
Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i], debugEnabled );
|
||||
types[i].resolve( value, session, entity, overridingEager );
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public final class TwoPhaseLoad {
|
|||
}
|
||||
|
||||
// we know value != LazyPropertyInitializer.UNFETCHED_PROPERTY
|
||||
Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i] );
|
||||
Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i], debugEnabled );
|
||||
hydratedState[i] = types[i].resolve( value, session, entity, overridingEager );
|
||||
}
|
||||
else {
|
||||
|
@ -376,21 +376,25 @@ public final class TwoPhaseLoad {
|
|||
* @return null if there is no overriding, true if it is overridden to eager and false if it is overridden to lazy
|
||||
*/
|
||||
private static Boolean getOverridingEager(
|
||||
SharedSessionContractImplementor session,
|
||||
String entityName,
|
||||
String associationName,
|
||||
Type type) {
|
||||
final SharedSessionContractImplementor session,
|
||||
final String entityName,
|
||||
final String associationName,
|
||||
final Type type,
|
||||
final boolean isDebugEnabled) {
|
||||
// Performance: check type.isCollectionType() first, as type.isAssociationType() is megamorphic
|
||||
if ( type.isCollectionType() || type.isAssociationType() ) {
|
||||
Boolean overridingEager = isEagerFetchProfile( session, entityName, associationName );
|
||||
final Boolean overridingEager = isEagerFetchProfile( session, entityName, associationName );
|
||||
|
||||
if ( overridingEager != null ) {
|
||||
LOG.debugf(
|
||||
"Overriding eager fetching using active fetch profile. EntityName: %s, associationName: %s, eager fetching: %s",
|
||||
entityName,
|
||||
associationName,
|
||||
overridingEager
|
||||
);
|
||||
//This method is very hot, and private so let's piggy back on the fact that the caller already knows the debugging state.
|
||||
if ( isDebugEnabled ) {
|
||||
if ( overridingEager != null ) {
|
||||
LOG.debugf(
|
||||
"Overriding eager fetching using active fetch profile. EntityName: %s, associationName: %s, eager fetching: %s",
|
||||
entityName,
|
||||
associationName,
|
||||
overridingEager
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return overridingEager;
|
||||
|
@ -405,8 +409,9 @@ public final class TwoPhaseLoad {
|
|||
// as otherwise this section becomes an hot allocation point.
|
||||
if ( loadQueryInfluencers.hasEnabledFetchProfiles() ) {
|
||||
final String role = entityName + '.' + associationName;
|
||||
final SessionFactoryImplementor factory = session.getFactory();
|
||||
for ( String fetchProfileName : loadQueryInfluencers.getEnabledFetchProfileNames() ) {
|
||||
FetchProfile fp = session.getFactory().getFetchProfile( fetchProfileName );
|
||||
FetchProfile fp = factory.getFetchProfile( fetchProfileName );
|
||||
Fetch fetch = fp.getFetchByRole( role );
|
||||
if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue