From 9ea3a936fb2d4ea4b1643a63211e9290c997da96 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 12 Aug 2020 11:21:30 +0200 Subject: [PATCH] HHH-14149 Improve efficiency of LazyAttributesMetadata#getLazyAttributeNames --- .../spi/interceptor/LazyAttributesMetadata.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributesMetadata.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributesMetadata.java index 8192d3d132..9da8a7c4ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributesMetadata.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributesMetadata.java @@ -26,6 +26,7 @@ import org.hibernate.mapping.Property; * @author Steve Ebersole */ public class LazyAttributesMetadata implements Serializable { + /** * Build a LazyFetchGroupMetadata based on the attributes defined for the * PersistentClass @@ -83,6 +84,8 @@ public class LazyAttributesMetadata implements Serializable { private final Map lazyAttributeDescriptorMap; private final Map> fetchGroupToAttributeMap; + private final Set fetchGroupNames; + private final Set lazyAttributeNames; public LazyAttributesMetadata(String entityName) { this( entityName, Collections.emptyMap(), Collections.emptyMap() ); @@ -95,6 +98,8 @@ public class LazyAttributesMetadata implements Serializable { this.entityName = entityName; this.lazyAttributeDescriptorMap = lazyAttributeDescriptorMap; this.fetchGroupToAttributeMap = fetchGroupToAttributeMap; + this.fetchGroupNames = Collections.unmodifiableSet( fetchGroupToAttributeMap.keySet() ); + this.lazyAttributeNames = Collections.unmodifiableSet( lazyAttributeDescriptorMap.keySet() ); } public String getEntityName() { @@ -110,11 +115,14 @@ public class LazyAttributesMetadata implements Serializable { } public Set getLazyAttributeNames() { - return lazyAttributeDescriptorMap.keySet(); + return lazyAttributeNames; } + /** + * @return an immutable set + */ public Set getFetchGroupNames() { - return fetchGroupToAttributeMap.keySet(); + return fetchGroupNames; } public boolean isLazyAttribute(String attributeName) { @@ -137,6 +145,10 @@ public class LazyAttributesMetadata implements Serializable { return list; } + /** + * @deprecated This method is not being used and as such will be removed + */ + @Deprecated public Set getAttributesInSameFetchGroup(String attributeName) { final String fetchGroupName = getFetchGroupName( attributeName ); return getAttributesInFetchGroup( fetchGroupName );