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
importorg.jetbrains.exposed.dao.LongEntityimportorg.jetbrains.exposed.dao.LongEntityClassimportorg.jetbrains.exposed.dao.id.EntityIDimportorg.jetbrains.exposed.dao.id.LongIdTableimportorg.jetbrains.exposed.sql.Databaseimportorg.jetbrains.exposed.sql.SchemaUtilsimportorg.jetbrains.exposed.sql.transactions.transactionobject ParentTable : LongIdTable() {
val name = varchar("name", 50)
}
classParentEntity(id:EntityID<Long>) : LongEntity(id) {
companionobject:LongEntityClass<ParentEntity>(ParentTable)
var name by ParentTable.name
}
object ChildTable : LongIdTable() {
val companyId = reference("company_id", ParentTable)
val name = varchar("name", 80)
}
classChildEntity(id:EntityID<Long>) : LongEntity(id) {
companionobject:LongEntityClass<ChildEntity>(ChildTable)
var parent by ParentEntity referencedOn ChildTable.companyId
var name by ChildTable.name
}
funmain() {
Database.connect("jdbc:postgresql://localhost:5432/xxx", driver ="org.postgresql.Driver", user ="xxx", password ="")
try {
val parentId = transaction {
SchemaUtils.create(ParentTable, ChildTable)
ParentEntity.new {
name ="parent1"
}.id.value
}
transaction {
ChildEntity.new(100L) {
parent =ParentEntity[parentId]
name ="child1"
}
}
} finally {
transaction {
SchemaUtils.drop(ParentTable, ChildTable)
}
}
}
Exception in thread "main" java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.last(_Collections.kt:362)
at org.jetbrains.exposed.sql.statements.BatchInsertStatement.allColumnsInDataSet(BatchInsertStatement.kt:59)
at org.jetbrains.exposed.sql.statements.BatchInsertStatement.getArguments(BatchInsertStatement.kt:63)
at org.jetbrains.exposed.sql.statements.InsertStatement.arguments(InsertStatement.kt:147)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:128)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert$default(Queries.kt:89)
at org.jetbrains.exposed.dao.EntityCache.flushInserts$exposed_dao(EntityCache.kt:113)
at org.jetbrains.exposed.dao.EntityCache.flush(EntityCache.kt:81)
at org.jetbrains.exposed.dao.EntityLifecycleInterceptor.flushEntities(EntityLifecycleInterceptor.kt:56)
at org.jetbrains.exposed.dao.EntityLifecycleInterceptor.beforeExecution(EntityLifecycleInterceptor.kt:13)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_core(Statement.kt:36)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:125)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:111)
at org.jetbrains.exposed.sql.Query.iterator(Query.kt:212)
at org.jetbrains.exposed.sql.IterableExKt$mapLazy$1.iterator(IterableEx.kt:124)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:221)
at org.jetbrains.exposed.dao.EntityClass.findById(EntityClass.kt:41)
at org.jetbrains.exposed.dao.EntityClass.get(EntityClass.kt:19)
at org.jetbrains.exposed.dao.EntityClass.get(EntityClass.kt:21)
at TestKt$main$1$1.invoke(Test.kt:40)
at TestKt$main$1$1.invoke(Test.kt)
at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:242)
at TestKt$main$1.invoke(Test.kt:39)
at TestKt$main$1.invoke(Test.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 TestKt.main(Test.kt:38)
at TestKt.main(Test.kt)
Process finished with exit code 1
The text was updated successfully, but these errors were encountered:
Reproduced in 0.19.3 (Not reproduced in 0.19.1)
Test.kt
The text was updated successfully, but these errors were encountered: