Question

When I set a Grails Quartz job like this:

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?

Was it helpful?

Solution

Only if you need the transaction.

Actually, the Quartz plugin creates a persistence context, but doesn't create a transaction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top