FileDocCategorySizeDatePackage
StatisticsTest.javaAPI DocHibernate 3.2.51665Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.legacy

StatisticsTest

public class StatisticsTest extends LegacyTestCase
author
Emmanuel Bernard

Fields Summary
Constructors Summary
public StatisticsTest(String x)

		super(x);
	
Methods Summary
public java.lang.String[]getMappings()

		return new String[] { "legacy/ABC.hbm.xml", "legacy/ABCExtends.hbm.xml" };
	
public static junit.framework.Testsuite()

		return new FunctionalTestClassTestSuite( StatisticsTest.class );
	
public voidtestSessionStats()

		
		SessionFactory sf = getSessions();
		Statistics stats = sf.getStatistics();
		boolean isStats = stats.isStatisticsEnabled();
		stats.clear();
		stats.setStatisticsEnabled(true);
		Session s = sf.openSession();
		assertEquals( 1, stats.getSessionOpenCount() );
		s.close();
		assertEquals( 1, stats.getSessionCloseCount() );
		s = sf.openSession();
		Transaction tx = s.beginTransaction();
		A a = new A();
		a.setName("mya");
		s.save(a);
		a.setName("b");
		tx.commit();
		s.close();
		assertEquals( 1, stats.getFlushCount() );
		s = sf.openSession();
		tx = s.beginTransaction();
		String hql = "from " + A.class.getName();
		Query q = s.createQuery(hql);
		q.list();
		tx.commit();
		s.close();
		assertEquals(1, stats.getQueryExecutionCount() );
		assertEquals(1, stats.getQueryStatistics(hql).getExecutionCount() );
		
		stats.setStatisticsEnabled(isStats);