Search code examples
grailsgrails-orm

Print Mysql queries produced by Grails


i want to get hold of Mysql queries produced by grails before or after executing.

 trainingList = PrivateTraining.findAll(query,parameter)

i want to print the complete mysql query which is executed by the above statement. is there anyway to print ?


Solution

  • Set this property in your DataSource.groovy:

    hibernate.show_sql=true
    

    Example:

    environments {
        development {
            dataSource {
                /* ---------------------- */
                hibernate.show_sql = true
                /* ---------------------- */
                dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
                url = "jdbc:mysql://localhost:3306/my-db"
                // ...