@Transactional
class SomeService {
@Transactional(readOnly=true)
def method() {
// do lots work
}
}
I would expect method called from the job would be a readOnly transaction. I only noticed it wasn't while I had sql logging on and noticed a bunch of dirty checks/updates.
It seems to ignore the annotation, adding Propagation.REQUIRES_NEW was not honored either.
If this same someService.method() is called from a controller it was readOnly as expected.
Only way to work around it was to not use the annotation but do Domain.withNewTransaction(readOnly: true) { .work. }
Job:
Service:
I would expect
method
called from the job would be a readOnly transaction. I only noticed it wasn't while I had sql logging on and noticed a bunch of dirty checks/updates.It seems to ignore the annotation, adding
Propagation.REQUIRES_NEW
was not honored either.If this same
someService.method()
is called from a controller it was readOnly as expected.Only way to work around it was to not use the annotation but do
Domain.withNewTransaction(readOnly: true) { .work. }