1

i want to see executed hql in my grails app as sql query in console. like in hibernate we can set this in config file. like

<property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="use_sql_comments">true</property>
kiran reddy
  • 128
  • 2
  • 14

1 Answers1

2

There are two things you have to do.

First, in your Datasource.groovy you have to enable logging of SQL:

dataSource {
   dbCreate = ...
   url = ...
   ...
   logSql = true
}

Secondly, you have to enable the log4j settings in your Config.groovy:

log4j = {
   ...
   debug 'org.hibernate.SQL'
   trace 'org.hibernate.type'
}

With both of these changes in place you will see your SQL/HQL statements being logged.

Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
  • i am facing this problem, [http://stackoverflow.com/questions/2536829/hibernate-show-real-sql], can i set up http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/ in grails – kiran reddy Jun 15 '14 at 07:29
  • That's a different question than the one you have posted here. I would recommend you post a new question asking how to setup P6Spy with Grails. – Joshua Moore Jun 15 '14 at 07:33