You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object Cats: IntIdTable() {
val name = varchar("name", 64)
}
class Cat(id: EntityID<Int>): IntEntity(id) {
companion object : IntEntityClass<Cat>(Cats)
var name by Cats.name
override fun equals(other: Any?): Boolean {
if(other == null) {
return false
}
return if(other is Cat) {
name == other.name
} else {
false
}
}
}
fun main(args: Array<String>) {
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver")
transaction {
SchemaUtils.create(Cats)
val cat = Cat.new(1) {
name = "Hamilton"
}
}
}
But after updating to 0.21.1 I am getting the following error:
Exception in thread "main" java.lang.IllegalStateException: com.example.Cats.name is not initialized yet
at org.jetbrains.exposed.sql.ResultRow.rawToColumnValue(ResultRow.kt:44)
at org.jetbrains.exposed.sql.ResultRow.get(ResultRow.kt:25)
at org.jetbrains.exposed.dao.Entity.lookup(Entity.kt:96)
at org.jetbrains.exposed.dao.Entity.getValue(Entity.kt:82)
at com.example.Cat.getName(App.kt)
at com.example.Cat.equals(App.kt:33)
at kotlin.jvm.internal.Intrinsics.areEqual(Intrinsics.java:162)
at org.jetbrains.exposed.dao.EntityClass.invalidateEntityInCache$exposed_dao(EntityClass.kt:67)
at org.jetbrains.exposed.dao.Entity.setValue(Entity.kt:100)
at com.example.Cat.setName(App.kt)
at com.example.AppKt$main$1$cat$1.invoke(App.kt:46)
at com.example.AppKt$main$1$cat$1.invoke(App.kt)
at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:243)
at com.example.AppKt$main$1.invoke(App.kt:45)
at com.example.AppKt$main$1.invoke(App.kt)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$1.invoke(ThreadLocalTransactionManager.kt:156)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$2.invoke(ThreadLocalTransactionManager.kt:197)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:205)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:196)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$transaction$1.invoke(ThreadLocalTransactionManager.kt:134)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:205)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:106)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:104)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:103)
at com.example.AppKt.main(App.kt:43)
Within EntityClass.kt I see:
internal open fun invalidateEntityInCache(o: Entity<ID>) {
val entityAlreadyFlushed = o.id._value != null
val sameDatabase = TransactionManager.current().db == o.db
if (entityAlreadyFlushed && sameDatabase) {
val currentEntityInCache = testCache(o.id)
if (currentEntityInCache == null) {
get(o.id) // Check that entity is still exists in database
warmCache().store(o)
} else if (currentEntityInCache != o) {
exposedLogger.error("Entity instance in cache differs from the provided: ${o::class.simpleName} with ID ${o.id.value}. Changes on entity could be missed.")
}
}
}
So this appears to be happening due to the newly created entity being compared to a cached instance. Since this is a newly created entity, why would the cache invalidation be performed?
The text was updated successfully, but these errors were encountered:
The code below works on version 0.13.7:
But after updating to 0.21.1 I am getting the following error:
Within EntityClass.kt I see:
So this appears to be happening due to the newly created entity being compared to a cached instance. Since this is a newly created entity, why would the cache invalidation be performed?
The text was updated successfully, but these errors were encountered: