Package org.hibernate.stat

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


    em.persist( book );
    assertEquals( 0, stats.getEntityInsertCount() );
    em.getTransaction().commit();

    em.clear(); //persist and clear
    stats.clear();
    stats.setStatisticsEnabled( true );

    Book bookReloaded = em.find( Book.class, book.id );

    book.name = "Le prince";
View Full Code Here


    Distributor res = new Distributor();
    res.setName( "Bruce" );
    item.setDistributors( new HashSet<Distributor>() );
    item.getDistributors().add( res );
    Statistics stats = ( ( HibernateEntityManagerFactory ) factory ).getSessionFactory().getStatistics();
    stats.clear();
    stats.setStatisticsEnabled( true );

    EntityManager em = getOrCreateEntityManager();
    em.getTransaction().begin();
View Full Code Here

    em.remove( second );
    em.remove( second.getDistributors().iterator().next() );
    em.getTransaction().commit();
    em.close();

    stats.clear();
    stats.setStatisticsEnabled( false );
  }

  public void testContains() throws Exception {
    EntityManager em = getOrCreateEntityManager();
View Full Code Here

    Distributor res = new Distributor();
    res.setName( "Bruce" );
    item.setDistributors( new HashSet<Distributor>() );
    item.getDistributors().add( res );
    Statistics stats = ( ( HibernateEntityManagerFactory ) emf ).getSessionFactory().getStatistics();
    stats.clear();
    stats.setStatisticsEnabled( true );

    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
View Full Code Here

    }
    em.remove( second );
    em.getTransaction().commit();
    em.close();

    stats.clear();
    stats.setStatisticsEnabled( false );
    emf.close();
  }

  public void testExternalJar() throws Exception {
View Full Code Here

        c2.setB2( anotherB2 );
      }
    }
    Statistics statistics = em.unwrap(Session.class).getSessionFactory().getStatistics();
    statistics.setStatisticsEnabled( true );
    statistics.clear();
    em.persist( c2 );
    long loaded = statistics.getEntityLoadCount();
    assertEquals( 0, loaded );
    em.flush();
    em.getTransaction().rollback();
View Full Code Here

    );
    criteria.setCacheable( true );

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

    );
    criteria.setCacheable( false );

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

    criteria.add( Restrictions.naturalId().set( "citizen", c1 ) );
    criteria.setCacheable( true );

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

    q = s.getNamedQuery( "night.moreRecentThan" );
    q.setDate( "date", inAMonth );
    assertEquals( 0, q.list().size() );
    Statistics stats = getSessions().getStatistics();
    stats.setStatisticsEnabled( true );
    stats.clear();
    q = s.getNamedQuery( "night.duration" );
    q.setParameter( "duration", 14l );
    assertEquals( 1, q.list().size() );
    assertEquals( 1, stats.getQueryCachePutCount() );
    q = s.getNamedQuery( "night.duration" );
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.