3

In hibernate,I'm using show_sql property=true and as well hibernate.generate_statistics=true .But this doesnt helped me lot. Awaiting for the suggestions and thanks in advance.

Steven Henry
  • 101
  • 2
  • 13
  • Hello Guys! Thanks for ur quick response. Please help me in doing it with Hibernate-JConsole. For your information, I have an appllication running on Mule Server ,Intellij IDE with hibernate and Spring configured. Can u please provide me detailed steps. – Steven Henry Jun 03 '16 at 05:25
  • 1
    Possible duplicate of [spring hibernate show query execution time](http://stackoverflow.com/questions/12656452/spring-hibernate-show-query-execution-time) – Ravi Parekh Sep 29 '16 at 10:22

4 Answers4

2

Do these steps :-

Change the log4j's level to trace on org.hibernate.stat

logging on the package: org.hibernate.stat at least on INFO and

set hibernate property: hibernate.generate_statistics=true

Afterwards all the SQLs will be logged and the time the query execution took.

It provides statistics on queries. If you want you can expose them via JMX and see them using JConsole (http://hibernate-jcons.sourceforge.net/).

Vikas Sharma
  • 745
  • 9
  • 19
  • I wanna do it with Hibernate JConsole . For your information, I have an appllication running on Mule Server ,Intellij IDE with hibernate and Spring configured. Can u please provide me detailed steps. I have gone through the reference which u provided but it doesnt helped me much – Steven Henry Jun 03 '16 at 05:22
  • 1
    Answer Copied from http://stackoverflow.com/questions/12656452/spring-hibernate-show-query-execution-time#18204269 – Ravi Parekh Sep 29 '16 at 10:21
2

You can also use Library datasource-proxy. Which will log the exact SQL query with appended parameters and execution time as well. This will help you better I guess.

0

Have a look at the JConsole Hibernate plugin: http://hibernate-jcons.sourceforge.net/usage.html

Using this you will be able to see all the queries being performed as well as running times.

Jonck van der Kogel
  • 2,983
  • 3
  • 23
  • 30
0

First step sperate Query building and query execution in two methods. And then apply @Loggable annotation on execution method. You can read the details of it here. Which will print the amount of time taken by method execution.