Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
I'm having trouble getting the new sessionStatistics stuff to work. In particular, I keep getting a java.lang.UnsupportedOperation whenever I try to invoke my session stats.
Here's my session factory creation where I turn stats on:
static {
fConfiguration = new Configuration().configure();
fSessionFactory = fConfiguration.buildSessionFactory();
fSessionFactory.getStatistics().setStatisticsEnabled(true);
}
Here's my session creation code where I actually create a session:
private static Session createNewSession() {
AuditInterceptor intercept = new AuditInterceptor();
Session s = fSessionFactory.openSession(intercept);
intercept.setSession(s);
s = (Session) (Proxy.newProxyInstance(Session.class.getClassLoader(),
new Class[] { Session.class }, new CorinnaSession(s)));
return s;
}
Here's the piece of code where I actually try to check my stats:
Session s = HibHelper.getSession();
SessionStatistics stats = s.getStatistics();
boolean foo = s.getSessionFactory().getStatistics().isStatisticsEnabled();
if (foo)
int x = stats.getCollectionCount();
return stats.getEntityCount();
Here's the top of the stack trace I keep getting:
org.hibernate.util.IdentityMap.keySet(IdentityMap.java:162) org.hibernate.stat.SessionStatisticsImpl.getCollectionCount(SessionStatisticsImpl.java:25)
forms.AdminActions.getEntityCount(AdminActions.java:20)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
Here's what my (3.0.5 copy I think of the relevant org.hibernate.util.IdentityMap.keySet() source looks like:
public Set keySet() {
// would need an IdentitySet for this!
throw new UnsupportedOperationException();
}
So, it's pretty obvious where the exception's coming from e.g. Hibernte is throwing it because that's literally the only think that method could ever possibly do.
My question though is can sesionStats be made to work? Is there some combination of voodoo and snake oil I can invoke which won't take me down this particular code path? Or do session stats just not work in 3.0.5?