user
07/03/2025, 1:01 AMjdaugherty
07/03/2025, 1:25 AMjdaugherty
07/03/2025, 1:27 AMuser
07/03/2025, 2:19 AM@Transactional
.
I had declared a method called getAccessToken
, and initially I noticed that the transactional context was lost when calling it.
But when I renamed the method to getAccessTokenByScope
, it started working properly and the transaction was preserved.
Not sure if this behavior is related to Grails/Groovy conventions around get*
methods — do you happen to know why this might be happening?jdaugherty
07/03/2025, 10:28 AMAri Bustamante
07/03/2025, 1:36 PM@Transactional
AccessTokenService {
AccessToken accessToken
//Needs an explicit @Transactional annotation because (maybe?), by "Grails magic" there is a default getter on the service that will delegate to AccessToken.get() when the Service name and Domain Class name match(??)
@Transactional
AccessToken getAccessToken() {
...
}
//Gets a transaction from the class-level @Transactional annotation, because its name doesn't match the service name or domain class name and so isn't a "bean method"
AccessToken getAccessTokenByScope() {
...
}
}
100% just guessing. I haven't tried it out, I haven't looked at what Grails actually does internally, and I'm not a contributor to the framework.
``````jdaugherty
07/03/2025, 1:57 PM