Václav Benes
11/15/2023, 9:45 PMPhones and another Operations. I have 1:N relationship.
class PhoneDao(id: EntityID<Long>) : LongEntity(id) {
companion object : LongEntityClass<PhoneDao>(PhoneTable)
...
val operations by OperationsDao referrersOn OperationsTable.deviceId
and
data object OperationsTable : LongIdTable("Operations") {
val deviceId = reference("device_id", PhoneTable)
...
}
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/N5CQhMyfEChantal Loncle
12/20/2023, 7:46 PMdevice_id as a compound string? From the snippets I'm seeing Phone.id is a Long and I'm assuming that PhonesTable is also a LongIdTable, so where does the transformation need to happen? On insert, on mapping, or when retrieving from the database?
I'm not sure it's exactly what you need, but it's possible to use transform() on an entity field mapping (Wiki). Here are some better test examples.Václav Benes
12/20/2023, 9:20 PMVáclav Benes
12/20/2023, 9:21 PM