01: //$Id: SessionStatisticsImpl.java 7688 2005-07-29 21:43:18Z epbernard $
02: package org.hibernate.stat;
03:
04: import java.util.Collections;
05: import java.util.Set;
06:
07: import org.hibernate.engine.SessionImplementor;
08:
09: /**
10: * @author Gavin King
11: */
12: public class SessionStatisticsImpl implements SessionStatistics {
13:
14: private final SessionImplementor session;
15:
16: public SessionStatisticsImpl(SessionImplementor session) {
17: this .session = session;
18: }
19:
20: public int getEntityCount() {
21: return session.getPersistenceContext().getEntityEntries()
22: .size();
23: }
24:
25: public int getCollectionCount() {
26: return session.getPersistenceContext().getCollectionEntries()
27: .size();
28: }
29:
30: public Set getEntityKeys() {
31: return Collections.unmodifiableSet(session
32: .getPersistenceContext().getEntitiesByKey().keySet());
33: }
34:
35: public Set getCollectionKeys() {
36: return Collections
37: .unmodifiableSet(session.getPersistenceContext()
38: .getCollectionsByKey().keySet());
39: }
40:
41: public String toString() {
42: return new StringBuffer().append("SessionStatistics[").append(
43: "entity count=").append(getEntityCount()).append(
44: "collection count=").append(getCollectionCount())
45: .append(']').toString();
46: }
47:
48: }
|