Stephcraft
04/24/2024, 11:32 PMProperty klass should be initialized before get.
?
When the uuid
property of the Profile
DAO is accessed here? Thanks.
class Profile(id: EntityID<UUID>) : Entity<UUID>(id) {
companion object: EntityClass<UUID, Profile>(ProfileTable)
var uuid by ProfileTable.uuid
init {
transaction {
val playerRecordCount = PlayerRecordTable.selectAll().where { PlayerRecordTable.playerUUID eq uuid /* <- here */ }.count().toInt()
}
}
}
Caused by: java.lang.IllegalStateException: Property klass should be initialized before get.
at kotlin.properties.NotNullVar.getValue(Delegates.kt:62)
at org.jetbrains.exposed.dao.Entity.getKlass(Entity.kt:48)
at org.jetbrains.exposed.dao.Entity.setValue(Entity.kt:231)
AdamW
04/25/2024, 5:08 AMStephcraft
04/25/2024, 1:33 PMAdamW
04/25/2024, 3:34 PMUUIDEntity
& UUIDEntityClass
here?
IMO you should compute aggregated data in a repository and keep the entity ”stupid”. Here the initializer runs when Exposed tries to construct the entity via reflection, which blows up.
If you’re sure you want such fields in your entity, then you should do it via a computed field or by setting up references between these two tables. See here and hereStephcraft
04/25/2024, 3:39 PMUUIDEntity
& UUIDEntityClass
. Better practice to use these probably?AdamW
04/25/2024, 3:40 PMStephcraft
04/25/2024, 3:44 PMStephcraft
04/25/2024, 3:46 PMStephcraft
04/25/2024, 3:49 PMAdamW
04/25/2024, 3:54 PMStephcraft
04/25/2024, 3:54 PMAdamW
04/25/2024, 3:55 PMEntityHook
?Stephcraft
04/25/2024, 3:56 PMEntityHook
, but I know when I post a new entry, so I update all aggregated data then.AdamW
04/25/2024, 7:12 PMStephcraft
04/25/2024, 8:25 PM