Java 类org.hibernate.stat.SessionStatistics 实例源码

项目:openbravo-brazil    文件:OBDal.java   
/**
 * Flushes the current state to the database.
 */
public void flush() {
  if (SessionHandler.isSessionHandlerPresent()) {
    long s1 = System.currentTimeMillis();
    SessionHandler.getInstance().getSession().flush();
    if (log.isDebugEnabled()) {
      long s2 = System.currentTimeMillis();
      SessionStatistics sessStat = SessionHandler.getInstance().getSession().getStatistics();
      dumpSessionEntities();
      log.debug(
          "Flush of " + sessStat.getEntityCount() + " entities and "
              + sessStat.getCollectionCount() + " collections took: " + (s2 - s1),
          new Throwable());
    }
  }
}
项目:openbravo-brazil    文件:OBDal.java   
/**
 * Utility method to log all entities loaded into the current hibernate session. Useful to debug
 * slow flush() calls.
 */
private void dumpSessionEntities() {
  SessionStatistics sessStat = SessionHandler.getInstance().getSession().getStatistics();
  log.debug("Dumping all entities in session");
  for (Object o : sessStat.getEntityKeys()) {
    log.debug(o);
  }
}
项目:openbravo-brazil    文件:ComputedColumnsTest.java   
@SuppressWarnings("unchecked")
private boolean dalObjectLoaded(String entityName, String id) {
  SessionStatistics stats = SessionHandler.getInstance().getSession().getStatistics();
  for (EntityKey k : (Set<EntityKey>) stats.getEntityKeys()) {
    if (entityName.equals(k.getEntityName()) && id.equals(k.getIdentifier())) {
      return true;
    }
  }
  return false;
}
项目:cacheonix-core    文件:SessionStatsTest.java   
public void testSessionStatistics() throws Exception {
    Session s = openSession();
    Transaction tx = s.beginTransaction();
    Statistics stats = getSessions().getStatistics();
    stats.clear();
    boolean isStats = stats.isStatisticsEnabled();
    stats.setStatisticsEnabled(true);
    Continent europe = fillDb(s);
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    SessionStatistics sessionStats = s.getStatistics();
    assertEquals( 0, sessionStats.getEntityKeys().size() );
    assertEquals( 0, sessionStats.getEntityCount() );
    assertEquals( 0, sessionStats.getCollectionKeys().size() );
    assertEquals( 0, sessionStats.getCollectionCount() );
    europe = (Continent) s.get( Continent.class, europe.getId() );
    Hibernate.initialize( europe.getCountries() );
    Hibernate.initialize( europe.getCountries().iterator().next() );
    assertEquals( 2, sessionStats.getEntityKeys().size() );
    assertEquals( 2, sessionStats.getEntityCount() );
    assertEquals( 1, sessionStats.getCollectionKeys().size() );
    assertEquals( 1, sessionStats.getCollectionCount() );
    tx.commit();
    s.close();

    stats.setStatisticsEnabled( isStats);

}
项目:lams    文件:SessionDelegatorBaseImpl.java   
@Override
public SessionStatistics getStatistics() {
    return session.getStatistics();
}
项目:lams    文件:SessionImpl.java   
@Override
public SessionStatistics getStatistics() {
    checkTransactionSynchStatus();
    return new SessionStatisticsImpl(this);
}
项目:cacheonix-core    文件:SessionImpl.java   
public SessionStatistics getStatistics() {
    checkTransactionSynchStatus();
    return new SessionStatisticsImpl(this);
}
项目:lams    文件:Session.java   
/**
 * Get the statistics for this session.
 *
 * @return The session statistics being collected for this session
 */
public SessionStatistics getStatistics();
项目:cacheonix-core    文件:Session.java   
/**
 * Get the statistics for this session.
 */
public SessionStatistics getStatistics();