Package org.hibernate.stat

Examples of org.hibernate.stat.Statistics.clear()


            BasicTransactionalTestCase.this.cleanupCache();

            Statistics stats = sessionFactory().getStatistics();
            stats.setStatisticsEnabled( true );
            stats.clear();
            assertEquals(
                  "Cache hits should be empty", 0, stats
                  .getNaturalIdCacheHitCount()
            );
View Full Code Here


   @Test
   public void testNaturalIdLoaderCached() throws Exception {
      final Statistics stats = sessionFactory().getStatistics();
      stats.setStatisticsEnabled( true );
      stats.clear();

      assertEquals( "NaturalId Cache Hits", 0, stats.getNaturalIdCacheHitCount() );
      assertEquals( "NaturalId Cache Misses", 0, stats.getNaturalIdCacheMissCount() );
      assertEquals( "NaturalId Cache Puts", 0, stats.getNaturalIdCachePutCount() );
      assertEquals( "NaturalId Cache Queries", 0, stats.getNaturalIdQueryExecutionCount() );
View Full Code Here

            State france = BasicTransactionalTestCase.this.getState(s, "Ile de France");
            NaturalIdLoadAccess naturalIdLoader = s.byNaturalId(Citizen.class);
            naturalIdLoader.using("ssn", "1234").using("state", france);

            //Not clearing naturalId caches, should be warm from entity loading
            stats.clear();

            // first query
            Citizen citizen = (Citizen) naturalIdLoader.load();
            assertNotNull(citizen);
            assertEquals("NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount());
View Full Code Here

      // TODO: Clear caches manually via cache manager (it's faster!!)
      this.cleanupCache();
      Thread.sleep(PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD + TimeUnit.SECONDS.toMillis(1));
      stats.setStatisticsEnabled( true );
      stats.clear();

      //Try NaturalIdLoadAccess
      withTx(tm, new Callable<Void>() {
         @Override
         public Void call() throws Exception {
View Full Code Here

            NaturalIdLoadAccess naturalIdLoader = s.byNaturalId(Citizen.class);
            naturalIdLoader.using( "ssn", "1234" ).using( "state", france );

            //Not clearing naturalId caches, should be warm from entity loading
            stats.setStatisticsEnabled( true );
            stats.clear();

            // first query
            Citizen loadedCitizen = (Citizen) naturalIdLoader.load();
            assertNotNull( loadedCitizen );
            assertEquals( "NaturalId Cache Hits", 1, stats.getNaturalIdCacheHitCount() );
View Full Code Here

    }

    public void testEmptySecondLevelCacheEntry() throws Exception {
        getSessions().evictEntity(Item.class.getName());
        Statistics stats = getSessions().getStatistics();
        stats.clear();
        SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics(getPrefixedRegionName(Item.class.getName()));
        Map cacheEntries = statistics.getEntries();
        assertEquals(0, cacheEntries.size());
    }
View Full Code Here

    public void zeroStats() {
        if (isLoggingEnabled()) {
            EntityManager entityManager = LookupUtil.getEntityManager();
            MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
            Statistics stats = PersistenceUtility.getStatisticsService(entityManager, platformMBeanServer);
            stats.clear();
        }
    }

    public long start() {
        if (isLoggingEnabled()) {
View Full Code Here

  public void testSessionStats() throws Exception {
   
    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() );
View Full Code Here

  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();
View Full Code Here

  public void testTransactionalOperationsWhenExtended() throws Exception {
    Book book = new Book();
    book.name = "Le petit prince";
    EntityManager em = getOrCreateEntityManager();
    Statistics stats = ( ( HibernateEntityManagerFactory ) factory ).getSessionFactory().getStatistics();
    stats.clear();
    stats.setStatisticsEnabled( true );

    em.persist( book );
    assertEquals( 0, stats.getEntityInsertCount() );
    em.getTransaction().begin();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.