From 1c73be8ba43f6699fd0ebce59291c89570c03004 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 31 Jan 2022 11:44:39 +0100 Subject: [PATCH] remove use of deprecated method --- .../interceptor/LazyAttributesMetadata.java | 28 +++++++++---------- .../AbstractLockUpgradeEventListener.java | 1 - 2 files changed, 13 insertions(+), 16 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 edbe9988a0..90889af46b 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 @@ -10,20 +10,21 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.persister.spi.PersisterCreationContext; +import static java.util.Collections.unmodifiableMap; +import static java.util.Collections.unmodifiableSet; + /** - * Information about all of the bytecode lazy attributes for an entity + * Information about the bytecode lazy attributes for an entity * * @author Steve Ebersole */ @@ -41,18 +42,15 @@ public class LazyAttributesMetadata implements Serializable { final Map lazyAttributeDescriptorMap = new LinkedHashMap<>(); final Map> fetchGroupToAttributesMap = new HashMap<>(); - int i = -1; int x = 0; - final Iterator itr = mappedEntity.getPropertyClosureIterator(); - while ( itr.hasNext() ) { - i++; - final Property property = (Property) itr.next(); + final List properties = mappedEntity.getPropertyClosure(); + for ( int i=0; i { - final MetadataImplementor metadata = creationContext.getMetadata(); - final PersistentClass entityBinding = metadata.getEntityBinding( entityName ); + final PersistentClass entityBinding = creationContext.getMetadata().getEntityBinding( entityName ); assert entityBinding != null; return entityBinding.hasSubclasses(); }, @@ -75,13 +73,13 @@ public class LazyAttributesMetadata implements Serializable { } for ( Map.Entry> entry : fetchGroupToAttributesMap.entrySet() ) { - entry.setValue( Collections.unmodifiableSet( entry.getValue() ) ); + entry.setValue( unmodifiableSet( entry.getValue() ) ); } return new LazyAttributesMetadata( mappedEntity.getEntityName(), - Collections.unmodifiableMap( lazyAttributeDescriptorMap ), - Collections.unmodifiableMap( fetchGroupToAttributesMap ) + unmodifiableMap( lazyAttributeDescriptorMap ), + unmodifiableMap( fetchGroupToAttributesMap ) ); } @@ -107,8 +105,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() ); + this.fetchGroupNames = unmodifiableSet( fetchGroupToAttributeMap.keySet() ); + this.lazyAttributeNames = unmodifiableSet( lazyAttributeDescriptorMap.keySet() ); } public String getEntityName() { diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractLockUpgradeEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractLockUpgradeEventListener.java index 781834fed8..8d1afde97b 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractLockUpgradeEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractLockUpgradeEventListener.java @@ -8,7 +8,6 @@ package org.hibernate.event.internal; import org.hibernate.LockOptions; import org.hibernate.engine.spi.EntityEntry; -import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreLogging; import org.hibernate.loader.ast.internal.LoaderHelper;