edrikL / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Hibernate statistics #224

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output? What do you see instead?

is it possible to get hibernate statistics as generated by hibernate using java 
melody
(http://docs.jboss.org/hibernate/orm/3.6/javadocs/org/hibernate/stat/Statistics.
html)

Original issue reported on code.google.com by jigar.pa...@gmail.com on 5 Jun 2012 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by evernat@free.fr on 10 Jun 2012 at 9:44

GoogleCodeExporter commented 9 years ago
I would suggest to publish the hibernate statistics in JMX and then to use 
javamelody to view the MBeans for hibernate.
See for example, the MBeans in the javamelody demo (which does not use 
hibernate):
http://demo.javamelody.cloudbees.net/monitoring?part=mbeans

To publish the hibernate statistics in JMX, you can do something like the 
following when the application is initialized:
//get your hibernate SF
SessionFactory sf = ...;
//get the available MBean servers
List list = MBeanServerFactory.findMBeanServer(null);
//take the first one, or create one
MBeanServer server;
if (!list.isEmpty()) {
   server = (MBeanServer) list.get(0);
} else {
   server = MBeanServerFactory.createMBeanServer();
}

//build the MBean name
ObjectName on = new ObjectName("Hibernate:type=statistics,application=sample");
StatisticsService mBean = new StatisticsService();
mBean.setSessionFactory(sf);
server.registerMBean(mBean, on);

More information: google or 
https://community.jboss.org/wiki/PublishingStatisticsThroughJMX

Original comment by evernat@free.fr on 10 Jun 2012 at 9:53

GoogleCodeExporter commented 9 years ago
+1 native support for hibernate stats would be useful

Original comment by jon.ner...@gmail.com on 10 Sep 2012 at 4:59