Skip to content

Commit

Permalink
🐛 Riktig bruk av transaksjonen i TotrinnsvurderingDao
Browse files Browse the repository at this point in the history
  • Loading branch information
chsko committed Oct 21, 2024
1 parent 7af8bf9 commit bade92c
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.helse.db

import kotliquery.Query
import kotliquery.sessionOf
import no.nav.helse.modell.totrinnsvurdering.TotrinnsvurderingOld
import java.util.UUID
Expand All @@ -22,9 +21,8 @@ class TotrinnsvurderingDao(private val dataSource: DataSource) : Totrinnsvurderi
override fun opprett(vedtaksperiodeId: UUID): TotrinnsvurderingOld =
sessionOf(dataSource).use { session ->
session.transaction { transaction ->
transaction.run {
hentAktiv(vedtaksperiodeId) ?: TransactionalTotrinnsvurderingDao(session).opprett(vedtaksperiodeId)
}
val transactionalDao = TransactionalTotrinnsvurderingDao(transaction)
transactionalDao.hentAktiv(vedtaksperiodeId) ?: transactionalDao.opprett(vedtaksperiodeId)
}
}

Expand Down Expand Up @@ -62,17 +60,4 @@ class TotrinnsvurderingDao(private val dataSource: DataSource) : Totrinnsvurderi
TransactionalTotrinnsvurderingDao(session).hentAktiv(oppgaveId)
}
}

private fun Query.tilTotrinnsvurdering() =
map { row ->
TotrinnsvurderingOld(
vedtaksperiodeId = row.uuid("vedtaksperiode_id"),
erRetur = row.boolean("er_retur"),
saksbehandler = row.uuidOrNull("saksbehandler"),
beslutter = row.uuidOrNull("beslutter"),
utbetalingIdRef = row.longOrNull("utbetaling_id_ref"),
opprettet = row.localDateTime("opprettet"),
oppdatert = row.localDateTimeOrNull("oppdatert"),
)
}.asSingle
}

0 comments on commit bade92c

Please sign in to comment.