Skip to content

Commit

Permalink
PI-2660 Fix stored procedure call (#4458)
Browse files Browse the repository at this point in the history
* PI-2660 bugfix

* PI-2660 bugfix
  • Loading branch information
joseph-bcl authored Nov 22, 2024
1 parent d7b92e5 commit 2aff051
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 31 deletions.

This file was deleted.

This file was deleted.

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 @@ -46,8 +46,6 @@ server.shutdown: immediate

spring:
datasource.url: jdbc:h2:file:./dev;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;AUTO_SERVER=true;AUTO_SERVER_PORT=9092
sql.init.mode: always
sql.init.data-locations: classpath:db/h2.sql
jpa:
hibernate.ddl-auto: create-drop

Expand Down

0 comments on commit 2aff051

Please sign in to comment.