HHH-14149 Improve efficiency of LazyAttributesMetadata#getLazyAttributeNames

This commit is contained in:
Sanne Grinovero 2020-08-12 11:21:30 +02:00
parent fb6bb820f1
commit fe3f27a733
1 changed files with 14 additions and 2 deletions

View File

@ -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<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap;
private final Map<String,Set<String>> fetchGroupToAttributeMap;
private final Set<String> fetchGroupNames;
private final Set<String> 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<String> getLazyAttributeNames() {
return lazyAttributeDescriptorMap.keySet();
return lazyAttributeNames;
}
/**
* @return an immutable set
*/
public Set<String> 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<String> getAttributesInSameFetchGroup(String attributeName) {
final String fetchGroupName = getFetchGroupName( attributeName );
return getAttributesInFetchGroup( fetchGroupName );