org.hibernate.stat.SessionStatistics Java Examples

The following examples show how to use org.hibernate.stat.SessionStatistics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionStatsTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);

}
 
Example #2
Source File: CacheHandlerTest.java    From pnc with Apache License 2.0 5 votes vote down vote up
private void printSessionStats(SessionStatistics sessionStatistics) {
    logger.debug("--- FIRST LEVEL STATS ---");
    logger.debug("Session stats collectionCount: {}", sessionStatistics.getCollectionCount());
    logger.debug("Session stats collectionKeys: {}", sessionStatistics.getCollectionKeys());
    logger.debug("Session stats entityCount: {}", sessionStatistics.getEntityCount());
    logger.debug("Session stats entityKeys: {}", sessionStatistics.getEntityKeys());
    logger.debug("--- --- --- --- --- ---");
}
 
Example #3
Source File: SessionDelegatorBaseImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SessionStatistics getStatistics() {
	return delegate.getStatistics();
}
 
Example #4
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SessionStatistics getStatistics() {
	checkTransactionSynchStatus();
	return new SessionStatisticsImpl( this );
}
 
Example #5
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SessionStatistics getStatistics() {
	checkTransactionSynchStatus();
	return new SessionStatisticsImpl(this);
}
 
Example #6
Source File: Session.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the statistics for this session.
 *
 * @return The session statistics being collected for this session
 */
SessionStatistics getStatistics();
 
Example #7
Source File: Session.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Get the statistics for this session.
 */
public SessionStatistics getStatistics();