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 97745d8768..f6eca86139 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 @@ -90,7 +90,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable { } } - this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] ); + this.affectedTableSpaces = spacesList.toArray( new String[ 0 ] ); } /** @@ -105,7 +105,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable { * @param session The session to which this request is tied. * @param tableSpaces The table spaces. */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings( { "unchecked", "rawtypes" } ) public BulkOperationCleanupAction(SharedSessionContractImplementor session, Set tableSpaces) { final LinkedHashSet spacesList = new LinkedHashSet<>(); spacesList.addAll( tableSpaces ); @@ -137,23 +137,26 @@ public class BulkOperationCleanupAction implements Executable, Serializable { } } - this.affectedTableSpaces = spacesList.toArray( new String[ spacesList.size() ] ); + this.affectedTableSpaces = spacesList.toArray( new String[ 0 ] ); } /** - * Check to determine whether the table spaces reported by an entity - * persister match against the defined affected table spaces. + * Check whether we should consider an entity as affected by the query. This + * defines inclusion of the entity in the clean-up. * * @param affectedTableSpaces The table spaces reported to be affected by * the query. * @param checkTableSpaces The table spaces (from the entity persister) * to check against the affected table spaces. * - * @return True if there are affected table spaces and any of the incoming - * check table spaces occur in that set. + * @return Whether the entity should be considered affected + * + * @implNote An entity is considered to be affected if either (1) the affected table + * spaces are not known or (2) any of the incoming check table spaces occur + * in that set. */ - private boolean affectedEntity(Set affectedTableSpaces, Serializable[] checkTableSpaces) { + private boolean affectedEntity(Set affectedTableSpaces, Serializable[] checkTableSpaces) { if ( affectedTableSpaces == null || affectedTableSpaces.isEmpty() ) { return true; } @@ -178,25 +181,21 @@ public class BulkOperationCleanupAction implements Executable, Serializable { @Override public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() { - return new AfterTransactionCompletionProcess() { - @Override - public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) { - for ( EntityCleanup cleanup : entityCleanups ) { - cleanup.release(); - } - entityCleanups.clear(); - - for ( NaturalIdCleanup cleanup : naturalIdCleanups ) { - cleanup.release(); - - } - entityCleanups.clear(); - - for ( CollectionCleanup cleanup : collectionCleanups ) { - cleanup.release(); - } - collectionCleanups.clear(); + return (success, session) -> { + for ( EntityCleanup cleanup : entityCleanups ) { + cleanup.release(); } + entityCleanups.clear(); + + for ( NaturalIdCleanup cleanup : naturalIdCleanups ) { + cleanup.release(); + } + naturalIdCleanups.clear(); + + for ( CollectionCleanup cleanup : collectionCleanups ) { + cleanup.release(); + } + collectionCleanups.clear(); }; }