Skip to content

Commit

Permalink
Wrap PGExecutionDAO createTasks in a single transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
VerstraeteBert committed May 7, 2024
1 parent e195ef6 commit cad47f4
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ private static String taskKey(TaskModel task) {
public List<TaskModel> createTasks(List<TaskModel> tasks) {
List<TaskModel> created = Lists.newArrayListWithCapacity(tasks.size());

for (TaskModel task : tasks) {
withTransaction(
connection -> {
withTransaction(
connection -> {
for (TaskModel task : tasks) {

validate(task);

task.setScheduledTime(System.currentTimeMillis());
Expand All @@ -155,7 +156,7 @@ public List<TaskModel> createTasks(List<TaskModel> tasks) {
+ task.getReferenceTaskName()
+ ", key="
+ taskKey);
return;
continue;
}

insertOrUpdateTaskData(connection, task);
Expand All @@ -164,8 +165,8 @@ public List<TaskModel> createTasks(List<TaskModel> tasks) {
updateTask(connection, task);

created.add(task);
});
}
}
});

return created;
}
Expand Down

0 comments on commit cad47f4

Please sign in to comment.