Symptoms:
Using Grails 1.2.2.
I created a Service and declared some methods like this:
def signUp = { arg1, arg2 -> //method body }
This is a valid way to declare a method, where you simply assign a closure to class member variable, and it works the same way as a method declared the usual Java way.
To enable transactionsupport in my Service, all I have to do is add this line to the class:
boolean transactional = true
And it should work. The problem is: it didn’t work.
Solution:
What is wrong with the code above is that methods declared using closures don’t get the transactional behavior injected. I just changed it to this:
def signUp(arg1, arg2){ //method body here }
I could not find anything telling me that the closure declaration shouldn’t work, so I just assumed it would work, since Grails and Groovy developers have implemented some pretty smart default behavior for other features. Also, I was using the closure syntax a lot, because the books and articles I was reading use it a lot.