At line 6 added 4 lines. |
Note: Using JDK 1.5 with the JAVA_OPTS and JConsole is optional, most app servers |
already have a MBean server, and MC4J (http://mc4j.sourceforge.net/) provides a JMX Console |
for most of them. |
|
At line 17 changed 1 line. |
Then, if you are using Spring, add this to your applicationContext-resources.xml file: |
Then, if you are using Spring, add this to your applicationContext-hibernate.xml file: |
At line 25 changed 1 line. |
<entry key="bean:name=myHibernateBean"> |
<entry key="Hibernate:type=statistics"> |
At line 40 added 1 line. |
<property name="sessionFactory"><ref local="sessionFactory"/></property> |
At line 45 added 11 lines. |
and then set the hibernate.generate_statistics property in your |
applicationContext-hibernate.xml file: |
|
{{{ |
<prop key="hibernate.generate_statistics">true</prop> |
}}} |
|
When you browse the MBeans (using JConsole.exe - which lives in the bin dir of your JDK 1.5 |
distribution), you should see Hibernate, if you double click on that node, you should see |
the Statistics Bean. |
|
At line 41 changed 1 line. |
already have the Hibernate libraries in the runtime classpath. |
already have the Hibernate libraries in the runtime classpath. Below are a couple of screenshots. |
At line 43 changed 2 lines. |
Note: statisticsEnabled does not get set to true properly in the statisticsBean |
(this is under investigation). |
<a href="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats1.png"><img src="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats1.png" width="300" style="margin-left: 20px"/></a> <a href="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats2.png"><img src="http://raibledesigns.com/wiki/attach/HibernateJMX/hibernatestats2.png" width="300" style="margin-left: 10px" /></a> |