Skip to content

Commit

Permalink
Fix: Delete all processedObjects when transactionId is null
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Feb 10, 2023
1 parent eb52cb5 commit a0371c5
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,13 @@ public ModifyObjectResult<SimulationResultType> deleteSimulatedProcessedObjects(
RootUpdateContext<SimulationResultType, QObject<MObject>, MObject> update = prepareUpdateContext(jdbcSession, SimulationResultType.class, SqaleUtils.oidToUuidMandatory(oid));

QProcessedObject alias = QProcessedObjectMapping.getProcessedObjectMapping().defaultAlias();
jdbcSession.newDelete(alias)
.where(alias.ownerOid.eq(SqaleUtils.oidToUuidMandatory(oid))
.and(alias.transactionId.eq(transactionId))
)
.execute();

var predicate = alias.ownerOid.eq(SqaleUtils.oidToUuidMandatory(oid));
// If transactionId is null, delete all processed objects
// otherwise delete only ones in particular transaction
predicate = transactionId != null ? alias.transactionId.eq(transactionId) : predicate;

jdbcSession.newDelete(alias).where(predicate).execute();
update.finishExecutionOwn();
jdbcSession.commit();
return new ModifyObjectResult<>(update.getPrismObject(), update.getPrismObject(), Collections.emptyList());
Expand Down

0 comments on commit a0371c5

Please sign in to comment.