1 package org.hibernate.stat; 3 4 import java.util.Collections ; 5 import java.util.Set ; 6 7 import org.hibernate.engine.SessionImplementor; 8 9 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().keySet().size(); 22 } 23 24 public int getCollectionCount() { 25 return session.getPersistenceContext().getCollectionEntries().keySet().size(); 26 } 27 28 public Set getEntityKeys() { 29 return Collections.unmodifiableSet( session.getPersistenceContext().getEntitiesByKey().keySet() ); 30 } 31 32 public Set getCollectionKeys() { 33 return Collections.unmodifiableSet( session.getPersistenceContext().getCollectionsByKey().keySet() ); 34 } 35 36 public String toString() { 37 return new StringBuffer () 38 .append("SessionStatistics[") 39 .append("entity count=").append( getEntityCount() ) 40 .append("collection count=").append( getCollectionCount() ) 41 .append(']') 42 .toString(); 43 } 44 45 } 46 | Popular Tags |