Skip to content

Commit

Permalink
PI-1586 added explicit save to old before new for constraint (#2444)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-britton-moj authored Oct 24, 2023
1 parent 4485596 commit 47cd02e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class PrisonManagerService(
val staff = getStaff(probationArea, team, allocation.manager, allocationDate)
val currentPom = prisonManagerRepository.findActiveManagerAtDate(personId, allocationDate)
val newPom = currentPom.changeTo(personId, allocationDate, probationArea, team, staff)
prisonManagerRepository.save(newPom)
newPom?.let { new ->
currentPom?.let { old -> prisonManagerRepository.saveAndFlush(old) }
prisonManagerRepository.save(new)
}
}

private fun getStaff(
Expand Down Expand Up @@ -84,6 +87,6 @@ class PrisonManagerService(
}
newPom
} else {
this
null
}
}

0 comments on commit 47cd02e

Please sign in to comment.