From de379ffd21952f99c4c27df50027403d70c85f28 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Fri, 23 Aug 2024 13:50:49 +0200 Subject: [PATCH] native query bulk operation otuside transaction should unlock cache region --- .../hibernate/action/internal/BulkOperationCleanupAction.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 03008c4c7a..0ca24448d8 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 @@ -163,7 +163,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() ) { + if ( session.isEventSource() && session.isTransactionInProgress() ) { session.asEventSource().getActionQueue().addAction( action ); } else { @@ -173,7 +173,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() ) { + if ( session.isEventSource() && session.isTransactionInProgress() ) { session.asEventSource().getActionQueue().addAction( action ); } else {