Skip to content

Commit

Permalink
HHH-13450 Do not compute the full role name of a collection unless ne…
Browse files Browse the repository at this point in the history
…cessary
  • Loading branch information
Sanne committed Jun 24, 2019
1 parent e133867 commit 7309cde
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Expand Up @@ -313,7 +313,7 @@ private static Boolean getOverridingEager(
String associationName,
Type type) {
if ( type.isAssociationType() || type.isCollectionType() ) {
Boolean overridingEager = isEagerFetchProfile( session, entityName + "." + associationName );
Boolean overridingEager = isEagerFetchProfile( session, entityName, associationName );

if ( LOG.isDebugEnabled() ) {
if ( overridingEager != null ) {
Expand All @@ -331,14 +331,19 @@ private static Boolean getOverridingEager(
return null;
}

private static Boolean isEagerFetchProfile(SharedSessionContractImplementor session, String role) {
private static Boolean isEagerFetchProfile(SharedSessionContractImplementor session, String entityName, String associationName) {
LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();

for ( String fetchProfileName : loadQueryInfluencers.getEnabledFetchProfileNames() ) {
FetchProfile fp = session.getFactory().getFetchProfile( fetchProfileName );
Fetch fetch = fp.getFetchByRole( role );
if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) {
return true;
// Performance: avoid concatenating entityName + "." + associationName when there is no need,
// as otherwise this section becomes an hot allocation point.
if ( loadQueryInfluencers.hasEnabledFetchProfiles() ) {
final String role = entityName + '.' + associationName;
for ( String fetchProfileName : loadQueryInfluencers.getEnabledFetchProfileNames() ) {
FetchProfile fp = session.getFactory().getFetchProfile( fetchProfileName );
Fetch fetch = fp.getFetchByRole( role );
if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) {
return true;
}
}
}

Expand Down
Expand Up @@ -151,7 +151,7 @@ protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister,
String relativePropertyPath = pos >= 0
? fullPath.substring( pos )
: rootPropertyName;
String fetchRole = persister.getEntityName() + "." + relativePropertyPath;
String fetchRole = persister.getEntityName() + '.' + relativePropertyPath;

for ( String profileName : getLoadQueryInfluencers().getEnabledFetchProfileNames() ) {
final FetchProfile profile = getFactory().getFetchProfile( profileName );
Expand Down
Expand Up @@ -58,7 +58,7 @@ public static FetchStyle determineFetchStyleByProfile(
final String relativePropertyPath = pos >= 0
? fullPath.substring( pos )
: rootPropertyName;
final String fetchRole = persister.getEntityName() + "." + relativePropertyPath;
final String fetchRole = persister.getEntityName() + '.' + relativePropertyPath;

for ( String profileName : loadQueryInfluencers.getEnabledFetchProfileNames() ) {
final FetchProfile profile = loadQueryInfluencers.getSessionFactory().getFetchProfile( profileName );
Expand Down

0 comments on commit 7309cde

Please sign in to comment.