有些东西没有被冲洗掉。正在发生的事情的简化示例:
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
我不明白我是否必须对 Session 和 Transaction 做一些事情以使数据保持不变,或者这是否是 GPars 中的错误。底层休眠级别发生了什么?
我希望最近创建的 Person 在并行闭包中可见。