From 329ccaa7a1469926a66df5ecd891ec1f62108d25 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 1 Dec 2022 22:09:40 +0000 Subject: [PATCH] HHH-15791 Avoid excessive Session casts to EventSource --- .../community/dialect/HSQLLegacyDialect.java | 3 +- .../internal/AbstractEntityInsertAction.java | 5 +-- .../internal/BulkOperationCleanupAction.java | 6 ++-- .../action/internal/CollectionAction.java | 10 +++--- .../internal/CollectionRecreateAction.java | 3 +- .../internal/CollectionRemoveAction.java | 7 ++-- .../internal/CollectionUpdateAction.java | 3 +- .../action/internal/EntityAction.java | 10 +++--- .../action/internal/EntityDeleteAction.java | 5 +-- .../internal/EntityIdentityInsertAction.java | 3 +- .../action/internal/EntityInsertAction.java | 3 +- .../action/internal/EntityUpdateAction.java | 3 +- .../action/internal/OrphanRemovalAction.java | 4 +-- .../QueuedOperationCollectionAction.java | 3 +- .../UnresolvedEntityInsertActions.java | 3 +- .../org/hibernate/action/spi/Executable.java | 6 ++-- .../internal/CollectionCacheInvalidator.java | 5 ++- .../org/hibernate/dialect/SpannerDialect.java | 4 +-- .../dialect/lock/LockingStrategy.java | 4 +-- ...timisticForceIncrementLockingStrategy.java | 5 ++- .../lock/OptimisticLockingStrategy.java | 5 ++- ...simisticForceIncrementLockingStrategy.java | 4 +-- .../PessimisticReadSelectLockingStrategy.java | 4 +-- .../PessimisticReadUpdateLockingStrategy.java | 4 +-- ...PessimisticWriteSelectLockingStrategy.java | 4 +-- ...PessimisticWriteUpdateLockingStrategy.java | 4 +-- .../dialect/lock/SelectLockingStrategy.java | 4 +-- .../dialect/lock/UpdateLockingStrategy.java | 4 +-- .../internal/NaturalIdResolutionsImpl.java | 32 +++++++++---------- .../org/hibernate/engine/spi/ActionQueue.java | 3 +- .../hibernate/engine/spi/ExecutableList.java | 3 +- .../engine/spi/SessionDelegatorBaseImpl.java | 6 ++++ .../spi/SharedSessionContractImplementor.java | 3 ++ .../AbstractLockUpgradeEventListener.java | 4 --- .../org/hibernate/internal/SessionImpl.java | 5 +++ .../internal/StatelessSessionImpl.java | 6 ++++ .../access/IdentifierLoadAccessImpl.java | 4 +-- .../loader/ast/internal/LoaderHelper.java | 3 +- .../ast/internal/MultiIdLoaderStandard.java | 10 +++--- .../loader/ast/spi/MultiIdEntityLoader.java | 3 +- .../entity/CacheEntityLoaderHelper.java | 2 +- .../entity/AbstractEntityPersister.java | 10 +++--- .../persister/entity/EntityPersister.java | 7 ++-- .../entity/AbstractEntityInitializer.java | 2 +- ...luesSourceProcessingStateStandardImpl.java | 7 ++-- .../GoofyPersisterClassProvider.java | 7 ++-- .../action/NonSortedExecutableListTest.java | 3 +- .../action/SortedExecutableListTest.java | 3 +- .../PersisterClassProviderTest.java | 7 ++-- .../orm/test/legacy/CustomPersister.java | 12 ++++--- 50 files changed, 153 insertions(+), 117 deletions(-) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacyDialect.java index d2561fa814..06cfffddbe 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacyDialect.java @@ -42,6 +42,7 @@ import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder; import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor; import org.hibernate.exception.spi.ViolatedConstraintNameExtractor; import org.hibernate.internal.CoreMessageLogger; @@ -704,7 +705,7 @@ public class HSQLLegacyDialect extends Dialect { } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) + public void lock(Object id, Object version, Object object, int timeout, EventSource session) throws StaleObjectStateException, JDBCException { if ( getLockMode().greaterThan( LockMode.READ ) ) { LOG.hsqldbSupportsOnlyReadCommittedIsolation(); diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java index e2752f3802..e94f1a83c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java @@ -19,6 +19,7 @@ import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.Status; +import org.hibernate.event.spi.EventSource; import org.hibernate.metamodel.mapping.NaturalIdMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; @@ -52,7 +53,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction { Object instance, boolean isVersionIncrementDisabled, EntityPersister persister, - SharedSessionContractImplementor session) { + EventSource session) { super( session, id, instance, persister ); this.state = state; this.isVersionIncrementDisabled = isVersionIncrementDisabled; @@ -177,7 +178,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction { protected abstract EntityKey getEntityKey(); @Override - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { super.afterDeserialize( session ); // IMPL NOTE: non-flushed changes code calls this method with session == null... // guard against NullPointerException diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/BulkOperationCleanupAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/BulkOperationCleanupAction.java index 391661771c..02cfa035c6 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/BulkOperationCleanupAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/BulkOperationCleanupAction.java @@ -164,7 +164,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable { public static void schedule(SharedSessionContractImplementor session, EntityPersister... affectedQueryables) { final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables ); if ( session.isEventSource() ) { - ( (EventSource) session ).getActionQueue().addAction( action ); + session.asEventSource().getActionQueue().addAction( action ); } else { action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session ); @@ -174,7 +174,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable { public static void schedule(SharedSessionContractImplementor session, Set affectedQueryables) { final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables ); if ( session.isEventSource() ) { - ( (EventSource) session ).getActionQueue().addAction( action ); + session.asEventSource().getActionQueue().addAction( action ); } else { action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session ); @@ -302,7 +302,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable { } @Override - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { // nop } } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java index c3165f9979..ed58820fa1 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java @@ -30,7 +30,7 @@ import org.hibernate.pretty.MessageHelper; public abstract class CollectionAction implements Executable, Serializable, Comparable { private transient CollectionPersister persister; - private transient SharedSessionContractImplementor session; + private transient EventSource session; private final PersistentCollection collection; private final Object key; @@ -40,7 +40,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp final CollectionPersister persister, final PersistentCollection collection, final Object key, - final SharedSessionContractImplementor session) { + final EventSource session) { this.persister = persister; this.session = session; this.key = key; @@ -57,7 +57,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp * * @param session The session being deserialized */ - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { if ( this.session != null || this.persister != null ) { throw new IllegalStateException( "already attached to a session." ); } @@ -122,7 +122,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp return finalKey; } - protected final SharedSessionContractImplementor getSession() { + protected final EventSource getSession() { return session; } @@ -185,7 +185,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp } protected EventSource eventSource() { - return (EventSource) getSession(); + return getSession(); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java index 751853c413..d2dde52689 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java @@ -9,6 +9,7 @@ package org.hibernate.action.internal; import org.hibernate.HibernateException; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCollectionRecreateEvent; import org.hibernate.event.spi.PostCollectionRecreateEventListener; import org.hibernate.event.spi.PreCollectionRecreateEvent; @@ -32,7 +33,7 @@ public final class CollectionRecreateAction extends CollectionAction { final PersistentCollection collection, final CollectionPersister persister, final Object id, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, collection, id, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java index d9a596442a..e0df7cb3c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java @@ -10,6 +10,7 @@ import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCollectionRemoveEvent; import org.hibernate.event.spi.PostCollectionRemoveEventListener; import org.hibernate.event.spi.PreCollectionRemoveEvent; @@ -43,7 +44,7 @@ public final class CollectionRemoveAction extends CollectionAction { final CollectionPersister persister, final Object id, final boolean emptySnapshot, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, collection, id, session ); if ( collection == null ) { throw new AssertionFailure("collection == null"); @@ -73,7 +74,7 @@ public final class CollectionRemoveAction extends CollectionAction { final CollectionPersister persister, final Object id, final boolean emptySnapshot, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, null, id, session ); if ( affectedOwner == null ) { throw new AssertionFailure("affectedOwner == null"); @@ -93,7 +94,7 @@ public final class CollectionRemoveAction extends CollectionAction { public CollectionRemoveAction( final CollectionPersister persister, final Object id, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, null, id, session ); emptySnapshot = false; affectedOwner = null; diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java index 60193b422d..17b0af6075 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java @@ -10,6 +10,7 @@ import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCollectionUpdateEvent; import org.hibernate.event.spi.PostCollectionUpdateEventListener; import org.hibernate.event.spi.PreCollectionUpdateEvent; @@ -38,7 +39,7 @@ public final class CollectionUpdateAction extends CollectionAction { final CollectionPersister persister, final Object id, final boolean emptySnapshot, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, collection, id, session ); this.emptySnapshot = emptySnapshot; } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java index ab9796e6d6..5c3e868784 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java @@ -33,7 +33,7 @@ public abstract class EntityAction private final Object id; private transient Object instance; - private transient SharedSessionContractImplementor session; + private transient EventSource session; private transient EntityPersister persister; private transient boolean veto; @@ -47,7 +47,7 @@ public abstract class EntityAction * @param persister The entity persister */ protected EntityAction( - SharedSessionContractImplementor session, + EventSource session, Object id, Object instance, EntityPersister persister) { @@ -123,7 +123,7 @@ public abstract class EntityAction * * @return The session from which this action originated. */ - public final SharedSessionContractImplementor getSession() { + public final EventSource getSession() { return session; } @@ -167,7 +167,7 @@ public abstract class EntityAction * @param session The session being deserialized */ @Override - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { if ( this.session != null || this.persister != null ) { throw new IllegalStateException( "already attached to a session." ); } @@ -181,7 +181,7 @@ public abstract class EntityAction } protected EventSource eventSource() { - return (EventSource) getSession(); + return getSession(); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java index c8d0de34b2..7b94558087 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java @@ -16,6 +16,7 @@ import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCommitDeleteEventListener; import org.hibernate.event.spi.PostDeleteEvent; import org.hibernate.event.spi.PostDeleteEventListener; @@ -55,7 +56,7 @@ public class EntityDeleteAction extends EntityAction { final Object instance, final EntityPersister persister, final boolean isCascadeDeleteEnabled, - final SessionImplementor session) { + final EventSource session) { super( session, id, instance, persister ); this.version = version; this.isCascadeDeleteEnabled = isCascadeDeleteEnabled; @@ -79,7 +80,7 @@ public class EntityDeleteAction extends EntityAction { * @param persister The entity persister * @param session The session */ - public EntityDeleteAction(final Object id, final EntityPersister persister, final SessionImplementor session) { + public EntityDeleteAction(final Object id, final EntityPersister persister, final EventSource session) { super( session, id, null, persister ); version = null; isCascadeDeleteEnabled = false; diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java index 077511ec89..049e5f24cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java @@ -12,6 +12,7 @@ import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCommitInsertEventListener; import org.hibernate.event.spi.PostInsertEvent; import org.hibernate.event.spi.PostInsertEventListener; @@ -49,7 +50,7 @@ public class EntityIdentityInsertAction extends AbstractEntityInsertAction { final Object instance, final EntityPersister persister, final boolean isVersionIncrementDisabled, - final SharedSessionContractImplementor session, + final EventSource session, final boolean isDelayed) { super( isDelayed ? generateDelayedPostInsertIdentifier() : null, diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java index 4e65f28172..8cae0da982 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java @@ -18,6 +18,7 @@ import org.hibernate.engine.spi.SessionEventListenerManager; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCommitInsertEventListener; import org.hibernate.event.spi.PostInsertEvent; import org.hibernate.event.spi.PostInsertEventListener; @@ -54,7 +55,7 @@ public class EntityInsertAction extends AbstractEntityInsertAction { final Object version, final EntityPersister persister, final boolean isVersionIncrementDisabled, - final SharedSessionContractImplementor session) { + final EventSource session) { super( id, state, instance, isVersionIncrementDisabled, persister, session ); this.version = version; } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java index 94b000d5ea..dfb737e582 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java @@ -20,6 +20,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.Status; import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostCommitUpdateEventListener; import org.hibernate.event.spi.PostUpdateEvent; import org.hibernate.event.spi.PostUpdateEventListener; @@ -76,7 +77,7 @@ public class EntityUpdateAction extends EntityAction { final Object instance, final Object rowId, final EntityPersister persister, - final SharedSessionContractImplementor session) { + final EventSource session) { super( session, id, instance, persister ); this.state = state; this.previousState = previousState; diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/OrphanRemovalAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/OrphanRemovalAction.java index 7507be0459..8152d751da 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/OrphanRemovalAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/OrphanRemovalAction.java @@ -6,14 +6,14 @@ */ package org.hibernate.action.internal; -import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.EntityPersister; public final class OrphanRemovalAction extends EntityDeleteAction { public OrphanRemovalAction( Object id, Object[] state, Object version, Object instance, - EntityPersister persister, boolean isCascadeDeleteEnabled, SessionImplementor session) { + EntityPersister persister, boolean isCascadeDeleteEnabled, EventSource session) { super( id, state, version, instance, persister, isCascadeDeleteEnabled, session ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/QueuedOperationCollectionAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/QueuedOperationCollectionAction.java index 09f6e2a824..cd2e1ebf16 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/QueuedOperationCollectionAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/QueuedOperationCollectionAction.java @@ -11,6 +11,7 @@ import org.hibernate.collection.spi.AbstractPersistentCollection; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.CollectionEntry; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.collection.CollectionPersister; /** @@ -35,7 +36,7 @@ public final class QueuedOperationCollectionAction extends CollectionAction { final PersistentCollection collection, final CollectionPersister persister, final Object id, - final SharedSessionContractImplementor session) { + final EventSource session) { super( persister, collection, id, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java b/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java index 509e554192..e63eea19c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java @@ -22,6 +22,7 @@ import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.Status; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.collections.IdentitySet; import org.hibernate.pretty.MessageHelper; @@ -293,7 +294,7 @@ public class UnresolvedEntityInsertActions { */ public static UnresolvedEntityInsertActions deserialize( ObjectInputStream ois, - SessionImplementor session) throws IOException, ClassNotFoundException { + EventSource session) throws IOException, ClassNotFoundException { final UnresolvedEntityInsertActions rtn = new UnresolvedEntityInsertActions(); diff --git a/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java b/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java index a0a8180d43..c6bb08c6d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java +++ b/hibernate-core/src/main/java/org/hibernate/action/spi/Executable.java @@ -9,7 +9,7 @@ package org.hibernate.action.spi; import java.io.Serializable; import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; /** * An operation which may be scheduled for later execution. Usually, the operation is a database @@ -59,7 +59,7 @@ public interface Executable { /** * Reconnect to session after deserialization * - * @param session The session being deserialized + * @param session The session being deserialized; must be an EventSource */ - void afterDeserialize(SharedSessionContractImplementor session); + void afterDeserialize(EventSource session); } diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/CollectionCacheInvalidator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/CollectionCacheInvalidator.java index afd8085b33..85d3d18964 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/CollectionCacheInvalidator.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/CollectionCacheInvalidator.java @@ -196,7 +196,7 @@ public class CollectionCacheInvalidator CollectionPersister persister, PersistentCollection collection, Object key, - SharedSessionContractImplementor session) { + EventSource session) { super( persister, collection, key, session ); } @@ -208,7 +208,6 @@ public class CollectionCacheInvalidator beforeExecutions(); return getAfterTransactionCompletionProcess(); } - - } + } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java index 940886af22..442895b117 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java @@ -26,7 +26,7 @@ import org.hibernate.dialect.unique.UniqueDelegate; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.mapping.Column; import org.hibernate.mapping.Constraint; @@ -877,7 +877,7 @@ public class SpannerDialect extends Dialect { @Override public void lock( - Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) + Object id, Object version, Object object, int timeout, EventSource session) throws StaleObjectStateException, LockingStrategyException { // Do nothing. Cloud Spanner doesn't have have locking strategies. } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java index 4f18de7177..8f19b1f6f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java @@ -7,7 +7,7 @@ package org.hibernate.dialect.lock; import org.hibernate.StaleObjectStateException; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; /** * A strategy abstraction for how locks are obtained in the underlying database. @@ -37,6 +37,6 @@ public interface LockingStrategy { * the requested lock. * @throws LockingStrategyException Indicates a failure in the lock attempt */ - void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) + void lock(Object id, Object version, Object object, int timeout, EventSource session) throws StaleObjectStateException, LockingStrategyException; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticForceIncrementLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticForceIncrementLockingStrategy.java index feec63a627..864a56966f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticForceIncrementLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticForceIncrementLockingStrategy.java @@ -10,7 +10,6 @@ import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.action.internal.EntityIncrementVersionProcess; import org.hibernate.engine.spi.EntityEntry; -import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.Lockable; @@ -43,13 +42,13 @@ public class OptimisticForceIncrementLockingStrategy implements LockingStrategy } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } final EntityEntry entry = session.getPersistenceContextInternal().getEntry( object ); // Register the EntityIncrementVersionProcess action to run just prior to transaction commit. - ( (EventSource) session ).getActionQueue().registerProcess( new EntityIncrementVersionProcess( object ) ); + session.getActionQueue().registerProcess( new EntityIncrementVersionProcess( object ) ); } protected LockMode getLockMode() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticLockingStrategy.java index 0d55afd325..031817248c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/OptimisticLockingStrategy.java @@ -9,7 +9,6 @@ package org.hibernate.dialect.lock; import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.action.internal.EntityVerifyVersionProcess; -import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.Lockable; @@ -41,12 +40,12 @@ public class OptimisticLockingStrategy implements LockingStrategy { } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { if ( !lockable.isVersioned() ) { throw new OptimisticEntityLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } // Register the EntityVerifyVersionProcess action to run just prior to transaction commit. - ( (EventSource) session ).getActionQueue().registerProcess( new EntityVerifyVersionProcess( object ) ); + session.getActionQueue().registerProcess( new EntityVerifyVersionProcess( object ) ); } protected LockMode getLockMode() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticForceIncrementLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticForceIncrementLockingStrategy.java index b9d181c80c..13c79b0c59 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticForceIncrementLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticForceIncrementLockingStrategy.java @@ -9,7 +9,7 @@ package org.hibernate.dialect.lock; import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.engine.spi.EntityEntry; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.Lockable; @@ -42,7 +42,7 @@ public class PessimisticForceIncrementLockingStrategy implements LockingStrategy } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadSelectLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadSelectLockingStrategy.java index fd0650f6ef..4574b80cd2 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadSelectLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadSelectLockingStrategy.java @@ -16,7 +16,7 @@ import org.hibernate.LockOptions; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; import org.hibernate.sql.SimpleSelect; @@ -53,7 +53,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { final String sql = determineSql( timeout ); final SessionFactoryImplementor factory = session.getFactory(); try { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadUpdateLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadUpdateLockingStrategy.java index 3fc2f838e1..cf515cc404 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadUpdateLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticReadUpdateLockingStrategy.java @@ -15,7 +15,7 @@ import org.hibernate.LockMode; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; @@ -69,7 +69,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy { } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteSelectLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteSelectLockingStrategy.java index 4c9baa0cb7..d845cb9e18 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteSelectLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteSelectLockingStrategy.java @@ -16,7 +16,7 @@ import org.hibernate.LockOptions; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; import org.hibernate.sql.SimpleSelect; @@ -52,7 +52,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { final String sql = determineSql( timeout ); final SessionFactoryImplementor factory = session.getFactory(); try { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteUpdateLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteUpdateLockingStrategy.java index 17e0309bcc..9557eee4bb 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteUpdateLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/PessimisticWriteUpdateLockingStrategy.java @@ -15,7 +15,7 @@ import org.hibernate.LockMode; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; @@ -68,7 +68,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy { } @Override - public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, int timeout, EventSource session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java index 3c8764b568..d9299b7a60 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java @@ -16,7 +16,7 @@ import org.hibernate.LockOptions; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; import org.hibernate.sql.SimpleSelect; @@ -51,7 +51,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy { Object version, Object object, int timeout, - SharedSessionContractImplementor session) throws StaleObjectStateException, JDBCException { + EventSource session) throws StaleObjectStateException, JDBCException { final String sql = determineSql( timeout ); final SessionFactoryImplementor factory = session.getFactory(); final Lockable lockable = getLockable(); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java b/hibernate-core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java index 8c65ec975e..f18678ab6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java @@ -15,7 +15,7 @@ import org.hibernate.LockMode; import org.hibernate.StaleObjectStateException; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.persister.entity.Lockable; import org.hibernate.pretty.MessageHelper; @@ -72,7 +72,7 @@ public class UpdateLockingStrategy implements LockingStrategy { Object version, Object object, int timeout, - SharedSessionContractImplementor session) throws StaleObjectStateException, JDBCException { + EventSource session) throws StaleObjectStateException, JDBCException { final String lockableEntityName = lockable.getEntityName(); if ( !lockable.isVersioned() ) { throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockableEntityName + "]" ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/NaturalIdResolutionsImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/NaturalIdResolutionsImpl.java index 0655dca2fc..ba96c68d88 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/NaturalIdResolutionsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/NaturalIdResolutionsImpl.java @@ -270,23 +270,23 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa if ( cacheAccess == null ) { return; } - + final SharedSessionContractImplementor s = session(); final EntityMappingType rootEntityDescriptor = persister.getRootEntityDescriptor(); final EntityPersister rootEntityPersister = rootEntityDescriptor.getEntityPersister(); - final Object cacheKey = cacheAccess.generateCacheKey( naturalIdValues, rootEntityPersister, session() ); + final Object cacheKey = cacheAccess.generateCacheKey( naturalIdValues, rootEntityPersister, s ); - final SessionFactoryImplementor factory = session().getFactory(); + final SessionFactoryImplementor factory = s.getFactory(); final StatisticsImplementor statistics = factory.getStatistics(); switch ( source ) { case LOAD: { - if ( CacheHelper.fromSharedCache( session(), cacheKey, cacheAccess ) != null ) { + if ( CacheHelper.fromSharedCache( s, cacheKey, cacheAccess ) != null ) { // prevent identical re-cachings return; } final boolean put = cacheAccess.putFromLoad( - session(), + s, cacheKey, id, null @@ -302,7 +302,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa break; } case INSERT: { - final boolean put = cacheAccess.insert( session(), cacheKey, id ); + final boolean put = cacheAccess.insert( s, cacheKey, id ); if ( put && statistics.isStatisticsEnabled() ) { statistics.naturalIdCachePut( rootEntityDescriptor.getNavigableRole(), @@ -310,7 +310,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa ); } - ( (EventSource) session() ).getActionQueue().registerProcess( + s.asEventSource().getActionQueue().registerProcess( (success, session) -> { if ( success ) { final boolean put1 = cacheAccess.afterInsert( session, cacheKey, id ); @@ -330,16 +330,16 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa break; } case UPDATE: { - final Object previousCacheKey = cacheAccess.generateCacheKey( previousNaturalIdValues, rootEntityPersister, session() ); + final Object previousCacheKey = cacheAccess.generateCacheKey( previousNaturalIdValues, rootEntityPersister, s ); if ( cacheKey.equals( previousCacheKey ) ) { // prevent identical re-caching, solves HHH-7309 return; } - final SoftLock removalLock = cacheAccess.lockItem( session(), previousCacheKey, null ); - cacheAccess.remove( session(), previousCacheKey); + final SoftLock removalLock = cacheAccess.lockItem( s, previousCacheKey, null ); + cacheAccess.remove( s, previousCacheKey); - final SoftLock lock = cacheAccess.lockItem( session(), cacheKey, null ); - final boolean put = cacheAccess.update( session(), cacheKey, id ); + final SoftLock lock = cacheAccess.lockItem( s, cacheKey, null ); + final boolean put = cacheAccess.update( s, cacheKey, id ); if ( put && statistics.isStatisticsEnabled() ) { statistics.naturalIdCachePut( rootEntityDescriptor.getNavigableRole(), @@ -347,12 +347,12 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa ); } - ( (EventSource) session() ).getActionQueue().registerProcess( + s.asEventSource().getActionQueue().registerProcess( (success, session) -> { - cacheAccess.unlockItem( session(), previousCacheKey, removalLock ); + cacheAccess.unlockItem( s, previousCacheKey, removalLock ); if (success) { final boolean put12 = cacheAccess.afterUpdate( - session(), + s, cacheKey, id, lock @@ -366,7 +366,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa } } else { - cacheAccess.unlockItem( session(), cacheKey, lock ); + cacheAccess.unlockItem( s, cacheKey, lock ); } } ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java index 60d5728af1..1b43efdcef 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java @@ -43,6 +43,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess; import org.hibernate.action.spi.Executable; import org.hibernate.cache.CacheException; import org.hibernate.engine.internal.NonNullableTransientDependencies; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; @@ -905,7 +906,7 @@ public class ActionQueue { * @throws IOException indicates a problem reading from the stream * @throws ClassNotFoundException Generally means we were unable to locate user classes. */ - public static ActionQueue deserialize(ObjectInputStream ois, SessionImplementor session) + public static ActionQueue deserialize(ObjectInputStream ois, EventSource session) throws IOException, ClassNotFoundException { final boolean traceEnabled = LOG.isTraceEnabled(); if ( traceEnabled ) { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ExecutableList.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/ExecutableList.java index ad593b1d37..36a776069e 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ExecutableList.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/ExecutableList.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Set; import org.hibernate.action.spi.Executable; +import org.hibernate.event.spi.EventSource; import org.hibernate.internal.util.collections.CollectionHelper; /** @@ -345,7 +346,7 @@ public class ExecutableList & Seria * * @param session The session with which to associate the {@code Executable}s */ - public void afterDeserialize(SessionImplementor session) { + public void afterDeserialize(EventSource session) { for ( E e : executables ) { e.afterDeserialize( session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index 3121a4614b..cfa6a5acfd 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -40,6 +40,7 @@ import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.event.spi.DeleteContext; +import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.MergeContext; import org.hibernate.event.spi.PersistContext; import org.hibernate.event.spi.RefreshContext; @@ -297,6 +298,11 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return delegate.isEventSource(); } + @Override + public EventSource asEventSource() { + return delegate.asEventSource(); + } + @Override public void afterScrollOperation() { delegate.afterScrollOperation(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java index 6c9bfe1fd1..cac1d156c4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java @@ -15,6 +15,7 @@ import org.hibernate.CacheMode; import org.hibernate.FlushMode; import org.hibernate.HibernateException; import org.hibernate.Interceptor; +import org.hibernate.event.spi.EventSource; import org.hibernate.query.Query; import org.hibernate.SharedSessionContract; import org.hibernate.Transaction; @@ -355,6 +356,8 @@ public interface SharedSessionContractImplementor boolean isEventSource(); + EventSource asEventSource(); + void afterScrollOperation(); boolean shouldAutoClose(); 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 8d1afde97b..6f7ba6a11b 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 @@ -9,11 +9,8 @@ package org.hibernate.event.internal; import org.hibernate.LockOptions; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.event.spi.EventSource; -import org.hibernate.internal.CoreLogging; import org.hibernate.loader.ast.internal.LoaderHelper; -import org.jboss.logging.Logger; - /** * A convenience base class for listeners that respond to requests to perform a * pessimistic lock upgrade on an entity. @@ -21,7 +18,6 @@ import org.jboss.logging.Logger; * @author Gavin King */ public abstract class AbstractLockUpgradeEventListener extends AbstractReassociateEventListener { - private static final Logger log = CoreLogging.logger( AbstractLockUpgradeEventListener.class ); /** * Performs a pessimistic lock upgrade on a given entity, if needed. diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index a79ceda910..9b03efb130 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -1813,6 +1813,11 @@ public class SessionImpl return true; } + @Override + public EventSource asEventSource() { + return this; + } + @Override public boolean isDefaultReadOnly() { return persistenceContext.isDefaultReadOnly(); 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 a5590458b0..2fc5f0ea0a 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java @@ -27,6 +27,7 @@ import org.hibernate.engine.spi.PersistenceContext; 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.EventSource; import org.hibernate.id.IdentifierGeneratorHelper; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.entity.EntityPersister; @@ -587,6 +588,11 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen return false; } + @Override + public EventSource asEventSource() { + throw new HibernateException( "Illegal Cast to EventSource - guard by invoking isEventSource() first" ); + } + public boolean isDefaultReadOnly() { return false; } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/access/IdentifierLoadAccessImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/access/IdentifierLoadAccessImpl.java index 9d915d2a09..1859757268 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/access/IdentifierLoadAccessImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/access/IdentifierLoadAccessImpl.java @@ -124,7 +124,7 @@ public class IdentifierLoadAccessImpl implements IdentifierLoadAccess, Jav @SuppressWarnings( "unchecked" ) protected T doGetReference(Object id) { final SessionImplementor session = context.getSession(); - final EventSource eventSource = (EventSource) session; + final EventSource eventSource = session.asEventSource(); final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers(); final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance(); @@ -169,7 +169,7 @@ public class IdentifierLoadAccessImpl implements IdentifierLoadAccess, Jav @SuppressWarnings( "unchecked" ) protected final T doLoad(Object id) { final SessionImplementor session = context.getSession(); - final EventSource eventSource = (EventSource) session; + final EventSource eventSource = session.asEventSource(); final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers(); final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance(); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java index cce346121a..f2f39110df 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java @@ -14,6 +14,7 @@ import org.hibernate.cache.spi.access.SoftLock; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.Status; +import org.hibernate.event.spi.EventSource; import org.hibernate.loader.LoaderLogging; import org.hibernate.persister.entity.EntityPersister; @@ -22,7 +23,7 @@ import org.hibernate.persister.entity.EntityPersister; */ public class LoaderHelper { - public static void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, SharedSessionContractImplementor session) { + public static void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource session) { LockMode requestedLockMode = lockOptions.getLockMode(); if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) { // The user requested a "greater" (i.e. more restrictive) form of diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdLoaderStandard.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdLoaderStandard.java index d0a7302aa5..5f856306ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdLoaderStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdLoaderStandard.java @@ -80,7 +80,7 @@ public class MultiIdLoaderStandard implements MultiIdEntityLoader { } @Override - public List load(Object[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session) { + public List load(Object[] ids, MultiIdLoadOptions loadOptions, EventSource session) { assert ids != null; if ( loadOptions.isOrderReturnEnabled() ) { @@ -93,7 +93,7 @@ public class MultiIdLoaderStandard implements MultiIdEntityLoader { private List performOrderedMultiLoad( Object[] ids, - SharedSessionContractImplementor session, + EventSource session, MultiIdLoadOptions loadOptions) { if ( log.isTraceEnabled() ) { log.tracef( "#performOrderedMultiLoad(`%s`, ..)", entityDescriptor.getEntityName() ); @@ -141,7 +141,7 @@ public class MultiIdLoaderStandard implements MultiIdEntityLoader { id, entityDescriptor.getMappedClass().getName(), lockOptions, - (EventSource) session, + session, getReadOnlyFromLoadQueryInfluencers(session) ); @@ -343,7 +343,7 @@ public class MultiIdLoaderStandard implements MultiIdEntityLoader { private List performUnorderedMultiLoad( Object[] ids, - SharedSessionContractImplementor session, + EventSource session, MultiIdLoadOptions loadOptions) { assert !loadOptions.isOrderReturnEnabled(); assert ids != null; @@ -382,7 +382,7 @@ public class MultiIdLoaderStandard implements MultiIdEntityLoader { id, entityDescriptor.getMappedClass().getName(), lockOptions, - (EventSource) session, + session, getReadOnlyFromLoadQueryInfluencers( session ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java index bd3e8545af..1468a707aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java @@ -9,6 +9,7 @@ package org.hibernate.loader.ast.spi; import java.util.List; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; /** * Loader subtype for loading multiple entities by multiple identifier values. @@ -17,5 +18,5 @@ public interface MultiIdEntityLoader extends MultiLoader { /** * Load multiple entities by id. The exact result depends on the passed options. */ - List load(K[] ids, MultiIdLoadOptions options, SharedSessionContractImplementor session); + List load(K[] ids, MultiIdLoadOptions options, EventSource session); } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/entity/CacheEntityLoaderHelper.java b/hibernate-core/src/main/java/org/hibernate/loader/entity/CacheEntityLoaderHelper.java index 1c27cbc294..985f3843f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/entity/CacheEntityLoaderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/entity/CacheEntityLoaderHelper.java @@ -70,7 +70,7 @@ public class CacheEntityLoaderHelper { EntityKey keyToLoad, LoadEventListener.LoadType options, LockOptions lockOptions, - SharedSessionContractImplementor session) { + EventSource session) { final Object old = session.getEntityUsingInterceptor( keyToLoad ); if ( old != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 3153a3d828..67e0c3e4de 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -2073,7 +2073,7 @@ public abstract class AbstractEntityPersister Object version, Object object, LockMode lockMode, - SharedSessionContractImplementor session) throws HibernateException { + EventSource session) throws HibernateException { getLocker( lockMode ).lock( id, version, object, LockOptions.WAIT_FOREVER, session ); } @@ -2083,7 +2083,7 @@ public abstract class AbstractEntityPersister Object version, Object object, LockOptions lockOptions, - SharedSessionContractImplementor session) throws HibernateException { + EventSource session) throws HibernateException { getLocker( lockOptions.getLockMode() ).lock( id, version, object, lockOptions.getTimeOut(), session ); } @@ -3493,8 +3493,8 @@ public abstract class AbstractEntityPersister final Object identifier = entityKey.getIdentifier(); Object loaded = null; - if ( canReadFromCache && session instanceof EventSource ) { - LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource) session, false ); + if ( canReadFromCache && session.isEventSource() ) { + LoadEvent loadEvent = new LoadEvent( identifier, entity, session.asEventSource(), false ); loaded = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( loadEvent, this, entityKey ); } if ( loaded == null ) { @@ -3544,7 +3544,7 @@ public abstract class AbstractEntityPersister } @Override - public List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) { + public List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) { return multiIdEntityLoader.load( ids, loadOptions, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java index e756c5afde..3959fdb7ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java @@ -26,6 +26,7 @@ import org.hibernate.engine.spi.EntityEntryFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.id.IdentifierGenerator; import org.hibernate.internal.FilterAliasGenerator; import org.hibernate.internal.TableGroupFilterAliasGenerator; @@ -550,17 +551,17 @@ public interface EntityPersister * * @return The loaded, matching entities */ - List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions); + List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions); /** * Do a version check (optional operation) */ - void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session); + void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session); /** * Do a version check (optional operation) */ - void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session); + void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session); /** * Persist an instance diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java index fba5bbceab..a0d15c0628 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java @@ -589,7 +589,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces // We have to query the second level cache if reference cache entries are used if ( instance == null && entityDescriptor.canUseReferenceCacheEntries() ) { instance = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( - (EventSource) rowProcessingState.getSession(), + rowProcessingState.getSession().asEventSource(), null, lockMode, entityDescriptor, diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java index 6230b9a5b0..09e0cdcb0b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java @@ -63,9 +63,10 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo this.processingOptions = processingOptions; this.loadingEntityEntryConsumer = loadingEntityEntryListener; - if ( executionContext.getSession() instanceof EventSource ) { - preLoadEvent = new PreLoadEvent( (EventSource) executionContext.getSession() ); - postLoadEvent = new PostLoadEvent( (EventSource) executionContext.getSession() ); + if ( executionContext.getSession().isEventSource() ) { + final EventSource eventSource = executionContext.getSession().asEventSource(); + preLoadEvent = new PreLoadEvent( eventSource ); + postLoadEvent = new PostLoadEvent( eventSource ); } else { preLoadEvent = null; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java index 707c8d228c..d0895272bf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java @@ -35,6 +35,7 @@ import org.hibernate.engine.spi.EntityEntryFactory; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.id.IdentifierGenerator; import org.hibernate.internal.FilterAliasGenerator; import org.hibernate.loader.ast.spi.MultiIdLoadOptions; @@ -357,16 +358,16 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver { } @Override - public List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) { + public List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) { return Collections.emptyList(); } @Override - public void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session) { } @Override - public void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session) { } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/NonSortedExecutableListTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/NonSortedExecutableListTest.java index 903f5e0489..66ed7c30c1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/NonSortedExecutableListTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/NonSortedExecutableListTest.java @@ -21,6 +21,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess; import org.hibernate.action.spi.Executable; import org.hibernate.engine.spi.ExecutableList; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.testing.orm.junit.BaseUnitTest; import org.junit.jupiter.api.AfterEach; @@ -97,7 +98,7 @@ public class NonSortedExecutableListTest { } @Override - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { this.afterDeserializeCalled = true; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/SortedExecutableListTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/SortedExecutableListTest.java index f6105c6684..724886f685 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/SortedExecutableListTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/engine/action/SortedExecutableListTest.java @@ -21,6 +21,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess; import org.hibernate.action.spi.Executable; import org.hibernate.engine.spi.ExecutableList; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.testing.orm.junit.BaseUnitTest; import org.junit.jupiter.api.AfterEach; @@ -95,7 +96,7 @@ public class SortedExecutableListTest { } @Override - public void afterDeserialize(SharedSessionContractImplementor session) { + public void afterDeserialize(EventSource session) { this.afterDeserializeCalled = true; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java index 2ab90dc3d4..48311c47ab 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PersisterClassProviderTest.java @@ -31,6 +31,7 @@ import org.hibernate.engine.spi.EntityEntryFactory; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.id.IdentifierGenerator; import org.hibernate.internal.FilterAliasGenerator; import org.hibernate.jpa.boot.spi.Bootstrap; @@ -397,16 +398,16 @@ public class PersisterClassProviderTest { } @Override - public List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) { + public List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) { return Collections.emptyList(); } @Override - public void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session) { } @Override - public void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session) { + public void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session) { } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java b/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java index c33c05549d..9d40800718 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/legacy/CustomPersister.java @@ -33,6 +33,7 @@ import org.hibernate.engine.spi.EntityEntryFactory; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.event.spi.EventSource; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.UUIDHexGenerator; import org.hibernate.internal.FilterAliasGenerator; @@ -398,7 +399,7 @@ public class CustomPersister implements EntityPersister { } @Override - public List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) { + public List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) { return Collections.emptyList(); } @@ -448,28 +449,29 @@ public class CustomPersister implements EntityPersister { } /** - * @see EntityPersister#lock(Object, Object, Object, LockMode, SharedSessionContractImplementor) + * @see EntityPersister#lock(Object, Object, Object, LockMode, EventSource) */ + @Override public void lock( Object id, Object version, Object object, LockOptions lockOptions, - SharedSessionContractImplementor session + EventSource session ) throws HibernateException { throw new UnsupportedOperationException(); } /** - * @see EntityPersister#lock(Object, Object, Object, LockMode, SharedSessionContractImplementor) + * @see EntityPersister#lock(Object, Object, Object, LockMode, EventSource) */ public void lock( Object id, Object version, Object object, LockMode lockMode, - SharedSessionContractImplementor session + EventSource session ) throws HibernateException { throw new UnsupportedOperationException();