某些東西沒有被刷新。發生了什麼事的一個簡單的例子:Grails,GPars和數據持久性
def testDemo() {
def person = new Person(...)
person.save(flush: true)
println "Number of people after save: " + Person.all.size()
def dummyList = [1, 2, 3, 4, 5]
GParsPool.withPool { num ->
println "Number of people after withPool: " + Person.all.size()
dummyList.eachParallel {
println "Number of people after eachParallel " + Person.all.size()
Person.withTransaction {
...
此輸出:
Number of people after save: 1
Number of people after withPool: 1
Number of people after eachParallel: 0
我不明白,如果我要做與會話和交易的東西,使數據保存,或者如果這是一個錯誤在GPars。底層hibernate層面上發生了什麼?
我希望最近創建的Person在並行閉包內可見。
你是如何克服這一點的? @Alison – Ramisetti