Skip to content

Commit

Permalink
PI-2660 bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-bcl committed Nov 22, 2024
1 parent d7b92e5 commit 315fdf0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ class Person(
interface PersonRepository : JpaRepository<Person, Long> {
@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
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +16,6 @@ import java.time.Period

@Service
class PersonService(
jdbcTemplate: JdbcTemplate,
auditedInteractionService: AuditedInteractionService,
private val personRepository: PersonRepository,
private val courtRepository: CourtRepository,
Expand All @@ -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 ->
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 315fdf0

Please sign in to comment.