John Pena
03/26/2021, 2:44 PMIllegalStateException: No transaction in context
. anyone know what i’m doing wrong here?
val breakdownDimensions = transaction {
Dimension.find {
Dimensions.id inList breakdownIds
}
}
for (dimension in breakdownDimensions) {
println(dimension.id)
}
Endre Deak
03/26/2021, 3:40 PMtransaction { }
?John Pena
03/26/2021, 3:41 PMJohn Pena
03/26/2021, 5:44 PMEndre Deak
03/26/2021, 9:44 PMJoel
03/29/2021, 7:13 PMDimension.find
returns a SizedIterable
which hasn't actually queried yet. The reason is that you could be asking for count, or existence, something that doesn't require the query to be completed in full. The query is actually occurring when you access the iterator using dimension in breakdownDimensions
. The fix would be to use:
Dimension.find { Dimensions.id inList breakdownIds }.toList()
John Pena
03/29/2021, 7:14 PM