0

In Our project we are using Hibernate with EJB. Currently I am working on performance tunning of Application, I got some slow queries from a Mysql Slow query log . But these queries are pure sql queries . I want to find respected hibernate query in our java code . So is there any way so that i can find such thing fastly .

Thanks

Sagar Varpe
  • 3,531
  • 4
  • 27
  • 43

1 Answers1

0

Put in your hibernate configuration file (usually hibernate.cfg.xml) these 2 property lines:

<hibernate-configuration>
   <session-factory>
    ...
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.format_sql" value="true"/>
    ...
   </session-factory>
</hibernate-configuration>
dcernahoschi
  • 14,968
  • 5
  • 37
  • 59
  • I got it. But the problem is i have to keep track of logs . what i want is is there any class in hibernate which will return me a SQL query if i give hibernate query to it . – Sagar Varpe Nov 08 '11 at 07:36
  • You can keep your hibernate query logs separately in a file using the hibernate logging. See http://stackoverflow.com/questions/436276/configuring-hibernate-logging-using-log4j-xml-config-file – dcernahoschi Nov 08 '11 at 07:51
  • Follow the hibernate output logs on every use case of your apps for performance tuning. – dcernahoschi Nov 08 '11 at 07:53