简体   繁体   English

withTransaction for Grails中的石英作业?

[英]withTransaction for Quartz Jobs in Grails?

When I set a Grails Quartz job like this: 当我像这样设置Grails Quartz作业时:

class TestJob {

    static triggers = {
        simple repeatInterval: 5000l // execute job once in 5 seconds
    }

def execute() {

   def users = User.getAll()
   users.each { user -> 
     user.enabled = true
     user.save()

  }

 }

}

Do I have to wrap the content of execute in a withTransaction block? 我是否必须将execute的内容包装在withTransaction块中?

Only if you need the transaction. 仅在您需要交易时。

Actually, the Quartz plugin creates a persistence context, but doesn't create a transaction. 实际上,Quartz插件会创建一个持久性上下文,但不会创建事务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM