From 315fdf07dfd159eb927e8cdd654316023af45dd2 Mon Sep 17 00:00:00 2001 From: "Joseph.Dundon" Date: Fri, 22 Nov 2024 15:04:35 +0000 Subject: [PATCH] PI-2660 bugfix --- .../digital/hmpps/integrations/delius/entity/Person.kt | 3 +++ .../gov/justice/digital/hmpps/service/PersonService.kt | 9 +-------- .../src/main/resources/application.yml | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt index a67d7cb702..e7ceabe2bb 100644 --- a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt +++ b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt @@ -104,4 +104,7 @@ class Person( interface PersonRepository : JpaRepository { @Query("SELECT SOUNDEX(:name) FROM DUAL", nativeQuery = true) fun getSoundex(name: String): String + + @Query(value = "SELECT offender_support_api.getNextCRN FROM DUAL", nativeQuery = true) + fun getNextCrn(): String } \ No newline at end of file diff --git a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonService.kt b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonService.kt index a5ecc16b7b..c28a0aa9a8 100644 --- a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonService.kt +++ b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonService.kt @@ -1,7 +1,5 @@ package uk.gov.justice.digital.hmpps.service -import org.springframework.jdbc.core.JdbcTemplate -import org.springframework.jdbc.core.simple.SimpleJdbcCall import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.audit.service.AuditableService @@ -18,7 +16,6 @@ import java.time.Period @Service class PersonService( - jdbcTemplate: JdbcTemplate, auditedInteractionService: AuditedInteractionService, private val personRepository: PersonRepository, private val courtRepository: CourtRepository, @@ -30,10 +27,6 @@ class PersonService( private val personAddressRepository: PersonAddressRepository ) : AuditableService(auditedInteractionService) { - private val generateCrn = SimpleJdbcCall(jdbcTemplate) - .withCatalogName("offender_support_api") - .withFunctionName("getNextCRN") - @Transactional fun insertPerson(defendant: Defendant, courtCode: String): InsertPersonResult = audit(BusinessInteractionCode.INSERT_PERSON) { audit -> @@ -108,7 +101,7 @@ class PersonService( } fun generateCrn(): String { - return generateCrn.executeFunction(String::class.java) + return personRepository.getNextCrn() } fun String.toDeliusGender() = ReferenceData.GenderCode.entries.find { it.commonPlatformValue == this }?.deliusValue diff --git a/projects/common-platform-and-delius/src/main/resources/application.yml b/projects/common-platform-and-delius/src/main/resources/application.yml index d3c0873bb6..980a59807b 100644 --- a/projects/common-platform-and-delius/src/main/resources/application.yml +++ b/projects/common-platform-and-delius/src/main/resources/application.yml @@ -78,6 +78,7 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH --- spring.config.activate.on-profile: delius-db spring: + sql.init.mode: never datasource: url: 'jdbc:oracle:thin:@//localhost:1521/XEPDB1' username: delius_pool