From 4a09da059f4fbf0403af85be3e20b5de98a7bb17 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 21 Oct 2024 20:34:02 +0100 Subject: [PATCH] MAN-28 - order licence conditions to match delius --- .../delius/sentence/entity/LicenceCondition.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt index c6ca5769a6..001d042dfb 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt @@ -4,6 +4,7 @@ import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData import java.time.LocalDate @@ -45,7 +46,17 @@ class LicenceCondition( interface LicenceConditionRepository : JpaRepository { + @Query( + """ + SELECT lc FROM LicenceCondition lc + JOIN FETCH lc.mainCategory mc + LEFT JOIN FETCH lc.subCategory + WHERE lc.disposalId = :disposalId + ORDER BY mc.description ASC + """ + ) fun findAllByDisposalId(disposalId: Long): List + } fun LicenceConditionRepository.getByLicenceConditionId(id: Long) = findById(id)