diff --git a/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java b/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java index adf917317dc..e30badf981b 100644 --- a/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java +++ b/drools-persistence/drools-persistence-api/src/main/java/org/drools/persistence/api/TransactionManagerHelper.java @@ -16,13 +16,14 @@ package org.drools.persistence.api; import java.util.Collections; +import java.util.Comparator; import java.util.LinkedHashSet; import java.util.Set; +import java.util.TreeSet; public class TransactionManagerHelper { private static final String APP_UPDETEABLE_RESOURCE = "app-updateable-resource"; - private static final String CMD_UPDETEABLE_RESOURCE = "cmd-updateable-resource"; public static void registerTransactionSyncInContainer(TransactionManager txm, OrderedTransactionSynchronization synchronization) { TransactionSynchronizationContainer container = (TransactionSynchronizationContainer)txm.getResource(TransactionSynchronizationContainer.RESOURCE_KEY); @@ -39,9 +40,17 @@ public static void addToUpdatableSet(TransactionManager txm, Transformable trans if (transformable == null) { return; } - Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm + .getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { - toBeUpdated = new LinkedHashSet(); + + toBeUpdated = new TreeSet<>(new Comparator() { + @Override + public int compare(Transformable o1, Transformable o2) { + int result = o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName()); + return result == 0 ? -1 : result; + } + }); txm.putResource(APP_UPDETEABLE_RESOURCE, toBeUpdated); } toBeUpdated.add(transformable); @@ -49,7 +58,8 @@ public static void addToUpdatableSet(TransactionManager txm, Transformable trans @SuppressWarnings("unchecked") public static void removeFromUpdatableSet(TransactionManager txm, Transformable transformable) { - Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm + .getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return; } @@ -58,11 +68,11 @@ public static void removeFromUpdatableSet(TransactionManager txm, Transformable @SuppressWarnings("unchecked") public static Set getUpdateableSet(TransactionManager txm) { - Set toBeUpdated = (Set) txm.getResource(APP_UPDETEABLE_RESOURCE); + Set toBeUpdated = (Set) txm + .getResource(APP_UPDETEABLE_RESOURCE); if (toBeUpdated == null) { return Collections.emptySet(); } - - return new LinkedHashSet(toBeUpdated); + return new LinkedHashSet<>(toBeUpdated); } }