Package org.hibernate.stat

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


   */
  public String evictedEntityCacheCheck(String CACHE_REGION_NAME){

    EntityManager em = emf.createEntityManager();
    Statistics stats = em.unwrap(Session.class).getSessionFactory().getStatistics();
    stats.clear();
    SecondLevelCacheStatistics emp2LCStats = stats.getSecondLevelCacheStatistics(CACHE_REGION_NAME+"Employee");
     
    try
      assertEquals("Expected no entities stored in the cache"+emp2LCStats, 0, emp2LCStats.getElementCountInMemory());
     
View Full Code Here


   */
  public String queryCacheCheck(String id){
   
    EntityManager em = emf.createEntityManager();
    Statistics stats = em.unwrap(Session.class).getSessionFactory().getStatistics();
    stats.clear();

    try{
          // the nextTimestamp from infinispan is "return System.currentTimeMillis() / 100;"
          Thread.sleep(1000);
         
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.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

    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

  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

    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.getTransaction().commit();
    em.close();

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

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

        c2.setB2( anotherB2 );
      }
    }
    Statistics statistics = ( (Session) em.getDelegate() ).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

   }

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

    final Item item = new Item( "chris", "Chris's Item" );
    final Item another = new Item( "another", "Owned Item" );
    item.addItem( another );
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.