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
packagecom.arcnor.test.exposedimportorg.jetbrains.exposed.dao.*importorg.jetbrains.exposed.sql.*importorg.jetbrains.exposed.sql.transactions.transactionobject Things : IntIdTable() {
val name = varchar("name", 42)
}
classThing(id:EntityID<Int>) : IntEntity(id) {
companionobject:IntEntityClass<Thing>(Things)
var name by Things.name
}
funmain(args:Array<String>) {
Database.connect("jdbc:postgresql://localhost:5432/test", driver ="org.postgresql.Driver", user ="postgres")
transaction {
SchemaUtils.create(Things)
println(Thing.new { name ="test" })
SchemaUtils.drop(Things)
}
}
The following output and error will be thrown, as if Exposed was trying to execute things more than once. If you remove the DROP, everything works fine:
09:47:10.690 [main] DEBUG Exposed - CREATE TABLE IF NOT EXISTS things (id SERIAL PRIMARY KEY, name VARCHAR(42) NOT NULL)
com.arcnor.test.exposed.Thing@700fb871
09:47:10.706 [main] DEBUG Exposed - DROP TABLE things
09:47:10.718 [main] INFO Exposed - Transaction attempt #0: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.. Statement: INSERT INTO things (name) VALUES ('test')
RETURNING "id"
java.sql.BatchUpdateException: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:472)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:791)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1547)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:50)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:10)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_main(Statement.kt:57)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:108)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:102)
at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:28)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:44)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert$default(Queries.kt:37)
at org.jetbrains.exposed.dao.EntityCache.flushInserts$exposed_main(Entity.kt:403)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:357)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:349)
at org.jetbrains.exposed.sql.Transaction.flushCache(Transaction.kt:72)
at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:61)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:71)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:49)
at com.arcnor.test.exposed.ExposedIssueKt.main(ExposedIssue.kt:75)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "things" does not exist
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2476)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2189)
... 20 common frames omitted
com.arcnor.test.exposed.Thing@769a1df5
09:47:10.734 [main] DEBUG Exposed - DROP TABLE things
09:47:10.736 [main] INFO Exposed - Transaction attempt #1: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.. Statement: INSERT INTO things (name) VALUES ('test')
RETURNING "id"
java.sql.BatchUpdateException: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:472)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:791)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1547)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:50)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:10)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_main(Statement.kt:57)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:108)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:102)
at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:28)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:44)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert$default(Queries.kt:37)
at org.jetbrains.exposed.dao.EntityCache.flushInserts$exposed_main(Entity.kt:403)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:357)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:349)
at org.jetbrains.exposed.sql.Transaction.flushCache(Transaction.kt:72)
at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:61)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:71)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:49)
at com.arcnor.test.exposed.ExposedIssueKt.main(ExposedIssue.kt:75)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "things" does not exist
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2476)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2189)
... 20 common frames omitted
com.arcnor.test.exposed.Thing@2438dcd
09:47:10.751 [main] DEBUG Exposed - DROP TABLE things
09:47:10.752 [main] INFO Exposed - Transaction attempt #2: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.. Statement: INSERT INTO things (name) VALUES ('test')
RETURNING "id"
java.sql.BatchUpdateException: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:472)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:791)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1547)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:50)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:10)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_main(Statement.kt:57)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:108)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:102)
at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:28)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:44)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert$default(Queries.kt:37)
at org.jetbrains.exposed.dao.EntityCache.flushInserts$exposed_main(Entity.kt:403)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:357)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:349)
at org.jetbrains.exposed.sql.Transaction.flushCache(Transaction.kt:72)
at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:61)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:71)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:49)
at com.arcnor.test.exposed.ExposedIssueKt.main(ExposedIssue.kt:75)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "things" does not exist
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2476)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2189)
... 20 common frames omitted
Exception in thread "main" java.sql.BatchUpdateException: Batch entry 0 INSERT INTO things (name) VALUES ('test')
RETURNING "id" was aborted: ERROR: relation "things" does not exist
Position: 13 Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:472)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:791)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1547)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:50)
at org.jetbrains.exposed.sql.statements.InsertStatement.executeInternal(InsertStatement.kt:10)
at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed_main(Statement.kt:57)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:108)
at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:102)
at org.jetbrains.exposed.sql.statements.Statement.execute(Statement.kt:28)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:44)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert$default(Queries.kt:37)
at org.jetbrains.exposed.dao.EntityCache.flushInserts$exposed_main(Entity.kt:403)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:357)
at org.jetbrains.exposed.dao.EntityCache.flush(Entity.kt:349)
at org.jetbrains.exposed.sql.Transaction.flushCache(Transaction.kt:72)
at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:61)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:71)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:58)
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:49)
at com.arcnor.test.exposed.ExposedIssueKt.main(ExposedIssue.kt:75)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "things" does not exist
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2476)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2189)
... 20 more
The text was updated successfully, but these errors were encountered:
For the following SSCCE:
The following output and error will be thrown, as if Exposed was trying to execute things more than once. If you remove the DROP, everything works fine:
The text was updated successfully, but these errors were encountered: