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.
-
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
-
1Possible 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 Answers
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/).

- 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
-
1Answer Copied from http://stackoverflow.com/questions/12656452/spring-hibernate-show-query-execution-time#18204269 – Ravi Parekh Sep 29 '16 at 10:21
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.

- 41
- 2
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.

- 2,983
- 3
- 23
- 30
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.

- 41
- 2