List<StateCommitter> committers = new ArrayList<>();
for( EntityStoreUnitOfWork entityStoreUnitOfWork : storeUnitOfWork.values() )
{
try
{
StateCommitter committer = entityStoreUnitOfWork.applyChanges();
committers.add( committer );
}
catch( Exception e )
{
// Cancel all previously prepared stores
for( StateCommitter committer : committers )
{
committer.cancel();
}
if( e instanceof ConcurrentEntityStateModificationException )
{
// If we cancelled due to concurrent modification, then create the proper exception for it!