From 7e36768c65fedc35f9bfb3601d2b0aa9463f976d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 9 Sep 2024 09:47:08 +0200 Subject: [PATCH] fix warnings in StatelessSessionImpl --- .../hibernate/internal/StatelessSessionImpl.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java index 3f9e3b2ea0..784bfe8aa3 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java @@ -7,7 +7,6 @@ package org.hibernate.internal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.function.BiConsumer; @@ -32,8 +31,6 @@ import org.hibernate.engine.spi.EntityHolder; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.PersistenceContext; -import org.hibernate.engine.spi.PersistentAttributeInterceptable; -import org.hibernate.engine.spi.PersistentAttributeInterceptor; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.hibernate.event.spi.PostDeleteEvent; @@ -71,7 +68,6 @@ import org.hibernate.tuple.entity.EntityMetamodel; import jakarta.persistence.EntityGraph; import jakarta.transaction.SystemException; -import static java.util.Arrays.asList; import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable; import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable; import static org.hibernate.engine.internal.Versioning.incrementVersion; @@ -760,11 +756,8 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen } } else if ( isPersistentAttributeInterceptable( association ) ) { - final PersistentAttributeInterceptable interceptable = asPersistentAttributeInterceptable( association ); - final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor(); - if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) { - final EnhancementAsProxyLazinessInterceptor proxyInterceptor = - (EnhancementAsProxyLazinessInterceptor) interceptor; + if ( asPersistentAttributeInterceptable( association ).$$_hibernate_getInterceptor() + instanceof EnhancementAsProxyLazinessInterceptor proxyInterceptor ) { proxyInterceptor.setSession( this ); try { proxyInterceptor.forceInitialize( association, null ); @@ -778,8 +771,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen } } } - else if ( association instanceof PersistentCollection ) { - final PersistentCollection persistentCollection = (PersistentCollection) association; + else if ( association instanceof PersistentCollection persistentCollection ) { if ( !persistentCollection.wasInitialized() ) { final CollectionPersister collectionDescriptor = getFactory().getMappingMetamodel() .getCollectionDescriptor( persistentCollection.getRole() );