Search code examples
grailstransactionsscaffolding

Is grails scaffolding transactional in any way?


I looked at Controller.groovy source code, and it looks like CRUD operations are not transactional (at least explicitly).

If I'm right, does it mean that dynamic scaffolding should not be used in production as is? Is there a way to make it transactional (i.e. can I modify Controller.groovy or whatever?)?


Solution

  • You are correct, the scaffolding is not transactional. This might be because grails and hibernate support data sources that don't support transactions, such as MySQL's MyISAM engine.

    You can change it to be transactional as follows:

    1. run grails install-templates
    2. edit src/templates/scaffolding/Controller.groovy

    Grails will use this template for generate-controller or whenever it dynamically generates a scaffolding controller.