Skip to content

Commit

Permalink
CDPS-975: Tweak to the JPQL to get the correct offender record (#2312)
Browse files Browse the repository at this point in the history
  • Loading branch information
brightonsbox authored Dec 13, 2024
1 parent ee0babc commit 0ea4837
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ interface OffenderRepository : JpaRepository<Offender, Long> {

@Lock(LockModeType.PESSIMISTIC_WRITE)
@QueryHints(value = [QueryHint(name = "jakarta.persistence.lock.timeout", value = "1000")])
@Query("select o from Offender o inner join o.bookings b where o.nomsId = :nomsId and b.bookingSequence = 1")
@Query("select o from OffenderBooking b inner join Offender o on b.offender = o where o.nomsId = :nomsId and b.bookingSequence = 1")
fun findLinkedToLatestBookingForUpdate(@NotNull nomsId: String): Optional<Offender>
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OffenderRepositoryTest {
// this prisoner has two offender records - ensure we get the right one
val offender = repository.findLinkedToLatestBookingForUpdate("A1234AL").orElseThrow()

assertThat(offender.id).isEqualTo(-1012L)
assertThat(offender.id).isEqualTo(-1012L) // Needs to be the one connected to the booking with booking seq of 1
assertThat(offender.allBookings).hasSizeGreaterThan(0)
}

Expand Down

0 comments on commit 0ea4837

Please sign in to comment.