Thread
#exposed
    Philipp Mayer

    Philipp Mayer

    2 years ago
    Hey guys! I'm currently working with Exposed and its a breeze! However, I stumbled upon a thing that I don't quite understand yet. I have the following table:
    object Sensors : IntIdTable() {
        val roomId = reference("id", Rooms.id).nullable()
        val name = text("name")
    }
    And now I just want to select all rows and map them to my domain Object:
    class Sensor(
            val id: Int?,
            val roomId: Int?,
            val name: String
    )
    
    Sensors.selectAll().map {
          Sensor(it[id], it[roomId], it[name])
    }
    However, if I do it as shown, I get an alert saying that
    it[id]
    is of type string (while I expect an int). Ist htere a better way? Why is it like that, even though my table definition is different? Thanks in advance!
    tapac

    tapac

    2 years ago
    You have to either provide explcit name for Seniors id column via IntIdTable
    columnName
    parameter or rename
    reference("id", Rooms.id)
    into
    reference("roomId", Rooms.id)
    .
    Philipp Mayer

    Philipp Mayer

    2 years ago
    That was a fast answer! So easy. Thanks a lot.