【发布时间】:2012-09-04 19:43:42
【问题描述】:
我正在尝试集成测试 Gorm 悲观锁,并通过多线程同时模拟来自多个服务器的访问,但在每个线程中我都没有得到预期的结果。这是我的代码:
@Test
void testLockInBetweenCheck() {
def tid = IdocTidInfo.findByTid("AC10870D0E12504F3E88D575") //here tid is not null
withPool{
[1,2].eachParallel{ tids ->
IdocTidInfo.withTransaction{ tid ->
def t = IdocTidInfo.findByTid("AC10870D0E12504F3E88D575") // here is t is null
我不知道发生了什么,我认为我的 Hibernate sessionFactory 没有绑定到每个线程,我应该使用 Domain.withTransaction,但它没有。
有什么帮助吗?
【问题讨论】:
-
发布问题的答案并将其标记为已接受的解决方案
标签: hibernate grails grails-orm grails-2.0 gpars