-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Trying to access Hibernate Statistics
PostPosted: Fri Feb 16, 2007 5:41 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Hello All,

I am currently using Hibernate 3.2, JPA annotations, EJB 3 in Glassfish.

I am interested in gathering the hibernate statistics through the Hibernate Statistics object to monitor 2nd level cache usage. I know this is supported by JMX but trying to dump out statistics in the app at the moment and currently using an injected entity manager.

Any clues on how to get access to these stats?

Thanks alot.

Regards,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 7:35 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
((Session) em.getDelegate()).getSessionFactory().getStatistics();

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 7:59 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Hi Emmanuel,

Thanks alot for the answer on this one!

Regards,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 10:26 am 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Emmanual,

I have one follow-up question. I assume this should work with an injected entity manager in Ejb 3 environment but receiving a class cast exception when casting to hibernate session object using Glassfish :

Code:
Statistics statistics =
                ((org.hibernate.Session) em.getDelegate())
                    .getSessionFactory()
                    .getStatistics();


Regards,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 2:04 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Emmanual,

I did get it working with the following :

Code:
HibernateEntityManager hem = ((HibernateEntityManager)em.getDelegate());
            Statistics stats = hem.getSession().getSessionFactory().getStatistics();


I had to enable the statistics gathering in code, not sure why it is not being picked up from persistence.xml :

<property name="hibernate.generate.statistics" value="true" />

Thanks,
Kurt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 6:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
<property name="hibernate.generate[b]_[/b]statistics" value="true" />

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
BTW, can you open a Glassfish issue,
They really should delegate getDelegate() to the underlying persistence provider for consistency with Java SE

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 7:21 pm 
Beginner
Beginner

Joined: Wed Jan 03, 2007 7:47 pm
Posts: 23
Location: Richardson, Texas
Emmanuel,

Thanks for the reply. I will look into opening glassfish issue.

Regards,
Kurt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.