Kevin
01/20/2019, 2:42 PMtransaction(Connection.TRANSACTION_SERIALIZABLE, 1) {
Message
.slice(Message.text)
.selectAll()
.limit(10)
.forEach { println(it) }
}
But when I try to return the rows and use them outside of the transaction, it doesn’t seem to work:
val messages = transaction(Connection.TRANSACTION_SERIALIZABLE, 1) {
Message
.slice(Message.text)
.selectAll()
.limit(10)
.toList()
}
messages.forEach { println(it) }
I’m getting java.lang.IllegalStateException: No transaction in context
.
When I set a breakpoint after the transaction, messages
has length 10, but trying to access any elements throws an exception.
I’m pretty new to this and wasn’t able to find anything by googling. Could someone help me figure out what I have wrong?tapac
01/21/2019, 7:56 AMtext
(along with blob
) field as whose kind of fields don't loaded eager (to not consume whole available memory) and that's why they are require transaction to be loaded.
In your case it could be fixed by:
Message
.slice(Message.text)
.selectAll()
.limit(10)
.map { it[Message.text] }
Kevin
01/21/2019, 8:09 AM