Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:31:27+00:00 2026-06-11T16:31:27+00:00

According to the grails docs, services are transactional by default. But, I know you

  • 0

According to the grails docs, services are transactional by default. But, I know you can get more fine grained control of transactions by using the Transactional attribute.

If I have a service such as

class MyService {

    @Transactional(...config...)
    def method1() { }

    def method2() { }

}

My understanding is that in this case, method1 will be transactional, but method2 will not.

If I have

class MyService {

    def method1() { }
    def method2() { }

}

Then both method1 and method2 will both be transactional.

Is this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:31:28+00:00Added an answer on June 11, 2026 at 4:31 pm

    If you want your service as transactional set to true the transactional property (this isn’t obligatory but if you want to make clear that the service is transactional):

    class MyService {
    
        static transactional = true
    
        def method1() { }
        def method2() { }
    
    }
    

    If you don’t want to:

    class MyService {
    
        static transactional = false
    
        @Transactional(...config...)
        def method1() { }
    
        def method2() { }
    
    }
    

    Another example (setting transactional property isn’t obligatory, but helps to be clear – if you are not the only coding this):

    import org.springframework.transaction.annotation.Transactional
    class BookService {
    
        @Transactional(readOnly = true)
        def listBooks() {
            Book.list()
        }
    
        @Transactional
        def updateBook() {
            // …
        }
    
        def deleteBook() {
            // …
        }
    }
    

    Another thing you can do is annotate the whole class and override the methods you need to be different:

    import org.springframework.transaction.annotation.Transactional
    @Transactional
    class BookService {
    
        @Transactional(readOnly = true)
        def listBooks() {
            Book.list()
        }
    
        def updateBook() {
            // …
        }
    
        def deleteBook() {
            // …
        }
    }
    

    Hope this helps 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to Grails API, we can retrieve all domain classes definition through GrailsApplication as
Basically I have 2 questions regarding grails filters. According to grails documentation you can
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,
I can't seem to figure out how to do memoization in Grails. According to
I'm using Grails in STS Spring, and according to the Xuggler docs I need
According to the Grails literature http://grails.org/doc/2.0.x/ref/Domain%20Classes/getAll.html I should be able to do this def
According to the Grails GORM guide , subclasses of domain classes share the same
I'm new to Grails (but not to Groovy or web development). I'm trying to
I am currently trying to specify custom error messages in grails for the default
I am trying to send mail through grails mail plugin. I configured according to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.