https://kotlinlang.org logo
#exposed
Title
# exposed
v

Václav Benes

11/15/2023, 9:45 PM
Hi, I have an issue with DAO API. I have two tables one is
Phones
and another
Operations
. I have 1:N relationship.
Copy code
class PhoneDao(id: EntityID<Long>) : LongEntity(id) {
    companion object : LongEntityClass<PhoneDao>(PhoneTable)
    ...
    val operations by OperationsDao referrersOn OperationsTable.deviceId
and
Copy code
data object OperationsTable : LongIdTable("Operations") {
    val deviceId = reference("device_id", PhoneTable)
...
}
Copy code
class OperationsDao(id: EntityID<Long>) : LongEntity(id) {
    companion object : LongEntityClass<OperationsDao>(OperationsTable)

    var deviceId by OperationsTable.deviceId
and issue is I have stored device_id as compound string
Type_id
type - string prefix in my case is
Phone
and
id
relates to id from phones. Complete device_id string is
Phone_1
. I need to somehow cast or transform
Phone.id.toString()
https://pl.kotl.in/N5CQhMyfE
2 Views