Source:
protected final void internalCompensate() { try { if (isQuotaDependant()) { rollBackQuota(); } } catch (NullPointerException e) { log.debug("RollbackQuota: failed (may be because quota is disabled)", e); } TransactionSupport.executeInNewTransaction(new TransactionMethod<Object>() { @Override public Object runInTransaction() { Deserializer deserializer = SerializationFactory.getFactory().createDeserializer(); List<BusinessEntitySnapshot> entitySnapshots = getBusinessEntitySnapshotDAO().getAllForCommandId(commandId); log.debugFormat("Command [id={0}]: {1} compensation data.", commandId, entitySnapshots.isEmpty() ? "No" : "Going over"); for (BusinessEntitySnapshot snapshot : entitySnapshots) { Class<Serializable> snapshotClass = (Class<Serializable>) ReflectionUtils.getClassFor(snapshot.getSnapshotClass()); Serializable snapshotData = deserializer.deserialize(snapshot.getEntitySnapshot(), snapshotClass); log.infoFormat("Command [id={0}]: Compensating {1} of {2}; snapshot: {3}.", commandId, snapshot.getSnapshotType(), snapshot.getEntityType(), (snapshot.getSnapshotType() == SnapshotType.CHANGED_ENTITY ? "id=" + snapshot.getEntityId() : snapshotData.toString())); Class<BusinessEntity<Serializable>> entityClass = (Class<BusinessEntity<Serializable>>) ReflectionUtils.getClassFor(snapshot.getEntityType()); GenericDao<BusinessEntity<Serializable>, Serializable> daoForEntity = DbFacade.getInstance().getDaoForEntity(entityClass); switch (snapshot.getSnapshotType()) { case CHANGED_STATUS_ONLY: EntityStatusSnapshot entityStatusSnapshot = (EntityStatusSnapshot) snapshotData; ((StatusAwareDao<Serializable, Enum<?>>) daoForEntity).updateStatus( entityStatusSnapshot.getId(), entityStatusSnapshot.getStatus()); break; case CHANGED_ENTITY: BusinessEntity<Serializable> entitySnapshot = (BusinessEntity<Serializable>) snapshotData; if (daoForEntity.get(entitySnapshot.getId()) == null) { daoForEntity.save(entitySnapshot); } else { daoForEntity.update(entitySnapshot); } break; case NEW_ENTITY_ID: daoForEntity.remove(snapshotData); break; } } cleanUpCompensationData(); return null; } }); }

Target:
protected final void internalCompensate() { try { if (isQuotaDependant()) { rollbackQuota(); } } catch (NullPointerException e) { log.debug("RollbackQuota: failed (may be because quota is disabled)", e); } TransactionSupport.executeInNewTransaction(new TransactionMethod<Object>() { @Override public Object runInTransaction() { Deserializer deserializer = SerializationFactory.getFactory().createDeserializer(); List<BusinessEntitySnapshot> entitySnapshots = getBusinessEntitySnapshotDAO().getAllForCommandId(commandId); log.debugFormat("Command [id={0}]: {1} compensation data.", commandId, entitySnapshots.isEmpty() ? "No" : "Going over"); for (BusinessEntitySnapshot snapshot : entitySnapshots) { Class<Serializable> snapshotClass = (Class<Serializable>) ReflectionUtils.getClassFor(snapshot.getSnapshotClass()); Serializable snapshotData = deserializer.deserialize(snapshot.getEntitySnapshot(), snapshotClass); log.infoFormat("Command [id={0}]: Compensating {1} of {2}; snapshot: {3}.", commandId, snapshot.getSnapshotType(), snapshot.getEntityType(), (snapshot.getSnapshotType() == SnapshotType.CHANGED_ENTITY ? "id=" + snapshot.getEntityId() : snapshotData.toString())); Class<BusinessEntity<Serializable>> entityClass = (Class<BusinessEntity<Serializable>>) ReflectionUtils.getClassFor(snapshot.getEntityType()); GenericDao<BusinessEntity<Serializable>, Serializable> daoForEntity = DbFacade.getInstance().getDaoForEntity(entityClass); switch (snapshot.getSnapshotType()) { case CHANGED_STATUS_ONLY: EntityStatusSnapshot entityStatusSnapshot = (EntityStatusSnapshot) snapshotData; ((StatusAwareDao<Serializable, Enum<?>>) daoForEntity).updateStatus( entityStatusSnapshot.getId(), entityStatusSnapshot.getStatus()); break; case CHANGED_ENTITY: BusinessEntity<Serializable> entitySnapshot = (BusinessEntity<Serializable>) snapshotData; if (daoForEntity.get(entitySnapshot.getId()) == null) { daoForEntity.save(entitySnapshot); } else { daoForEntity.update(entitySnapshot); } break; case NEW_ENTITY_ID: daoForEntity.remove(snapshotData); break; } } cleanUpCompensationData(); return null; } }); }