Tinkoff/kora

Koltin repositories is still broken for single result

Olex1313 opened this issue · 0 comments

Given repository

interface EntityRepository{
 fun findEntity(id): Entity?
 }

Generates repository with implementation like this

          _stmt.executeQuery().use { _rs ->
           val _result = _findByIdWithHidden_resultMapper.apply(_rs)
           _telemetry.close(null)
           return _result
         }

And mapper like this

@Generated("ru.tinkoff.kora.database.symbol.processor.jdbc.extension.JdbcTypesExtension")
public class `$Entity_JdbcResultSetMapper`() : JdbcResultSetMapper<Entity> {
 public override fun apply(_rs: ResultSet): Partner {
   val _idx_id = _rs.findColumn("id");
   val id = _rs.getLong(_idx_id)
   val _row = Entity(id)
   return _row
 }
}

Perhaps it should implement JdbcResultSetMapper<Entity?> and call next(), because right now it throws SQL exception with cause - ResultSet not positioned properly, you need to call next