Java 类org.hibernate.stat.EntityStatistics 实例源码

项目:elpaaso-core    文件:ManageStatisticsImpl.java   
private Map<String, Long> getStatsValues(Collection<Class> entities) {
    Statistics stats = getStats();
    Map<String, Long> statistics = new HashMap<String, Long>();
    statistics.put("Number of connection requests", stats.getConnectCount());
    statistics.put("Sessions opened", stats.getSessionOpenCount());
    // statistics.put("Sessions closed", stats.getSessionCloseCount());
    statistics.put("Transactions", stats.getTransactionCount());
    // statistics.put("Successful transactions", stats.getSuccessfulTransactionCount());
    // statistics.put("Successful transactions", stats.getSuccessfulTransactionCount());
    statistics.put("Queries executed", stats.getQueryExecutionCount());
    for(Class entity : entities) {
        EntityStatistics eStats = stats.getEntityStatistics(entity.getName());
        statistics.put(entity.getSimpleName() + " Fetched", eStats.getFetchCount());
        statistics.put(entity.getSimpleName() + " Loaded", eStats.getLoadCount());
        statistics.put(entity.getSimpleName() + " Inserted", eStats.getInsertCount());
        statistics.put(entity.getSimpleName() + " Deleted", eStats.getDeleteCount());
        statistics.put(entity.getSimpleName() + " Updated", eStats.getUpdateCount());
    }
    return statistics;
}
项目:lams    文件:ConcurrentStatisticsImpl.java   
/**
 * find entity statistics per name
 *
 * @param entityName entity name
 *
 * @return EntityStatistics object
 */
public EntityStatistics getEntityStatistics(String entityName) {
    ConcurrentEntityStatisticsImpl es = (ConcurrentEntityStatisticsImpl) entityStatistics.get( entityName );
    if ( es == null ) {
        es = new ConcurrentEntityStatisticsImpl( entityName );
        ConcurrentEntityStatisticsImpl previous;
        if ( ( previous = (ConcurrentEntityStatisticsImpl) entityStatistics.putIfAbsent(
                entityName, es
        ) ) != null ) {
            es = previous;
        }
    }
    return es;
}
项目:cacheonix-core    文件:DynamicMapOneToOneTest.java   
public void testOneToOneOnSubclass() {
    Map person = new HashMap();
    person.put( "name", "Steve" );
    Map address = new HashMap();
    address.put( "zip", "12345" );
    address.put( "state", "TX" );
    address.put( "street", "123 Main St" );

    person.put( "address", address );
    address.put( "owner", person );

    Session s = openSession();
    s.beginTransaction();
    s.persist( "Person", person );
    s.getTransaction().commit();
    s.close();

    s = openSession();
    s.beginTransaction();

    EntityStatistics addressStats = getSessions().getStatistics().getEntityStatistics( "Address" );

    person = ( Map ) s.createQuery( "from Person p join fetch p.address" ).uniqueResult();
    assertNotNull( "could not locate person", person );
    assertNotNull( "could not locate persons address", person.get( "address" ) );
    s.clear();

    Object[] tuple = ( Object[] ) s.createQuery( "select p.name, p from Person p join fetch p.address" ).uniqueResult();
    assertEquals( tuple.length, 2 );
    person = ( Map ) tuple[1];
    assertNotNull( "could not locate person", person );
    assertNotNull( "could not locate persons address", person.get( "address" ) );

    s.delete( "Person", person );

    s.getTransaction().commit();
    s.close();

    assertEquals( addressStats.getFetchCount(), 0 );
}
项目:lemon    文件:StatisticsWrapper.java   
public EntityStatistics getEntityStatistics(String entityName) {
    return null;
}
项目:cacheonix-core    文件:StatisticsService.java   
/**
 * @see StatisticsServiceMBean#getEntityStatistics(java.lang.String)
 */
public EntityStatistics getEntityStatistics(String entityName) {
    return stats.getEntityStatistics(entityName);
}
项目:cacheonix-core    文件:QueryCacheTest.java   
public void testQueryCacheInvalidation() throws Exception {

    getSessions().evictQueries();
    getSessions().getStatistics().clear();

    final String queryString = "from Item i where i.name='widget'";

    Session s = openSession();
    Transaction t = s.beginTransaction();
    s.createQuery( queryString ).setCacheable(true).list();
    Item i = new Item();
    i.setName("widget");
    i.setDescription("A really top-quality, full-featured widget.");
    s.save(i);
    t.commit();
    s.close();

    QueryStatistics qs = s.getSessionFactory().getStatistics().getQueryStatistics( queryString );
    EntityStatistics es = s.getSessionFactory().getStatistics().getEntityStatistics( Item.class.getName() );

    Thread.sleep(200);

    s = openSession();
    t = s.beginTransaction();
    List result = s.createQuery( queryString ).setCacheable(true).list();
    assertEquals( result.size(), 1 );
    t.commit();
    s.close();

    assertEquals( qs.getCacheHitCount(), 0 );

    s = openSession();
    t = s.beginTransaction();
    result = s.createQuery( queryString ).setCacheable(true).list();
    assertEquals( result.size(), 1 );
    t.commit();
    s.close();

    assertEquals( qs.getCacheHitCount(), 1 );
    assertEquals( s.getSessionFactory().getStatistics().getEntityFetchCount(), 0 );

    s = openSession();
    t = s.beginTransaction();
    result = s.createQuery( queryString ).setCacheable(true).list();
    assertEquals( result.size(), 1 );
    assertTrue( Hibernate.isInitialized( result.get(0) ) );
    i = (Item) result.get(0);
    i.setName("Widget");
    t.commit();
    s.close();

    assertEquals( qs.getCacheHitCount(), 2 );
    assertEquals( qs.getCacheMissCount(), 2 );
    assertEquals( s.getSessionFactory().getStatistics().getEntityFetchCount(), 0 );

    Thread.sleep(200);

    s = openSession();
    t = s.beginTransaction();
    result = s.createQuery( queryString ).setCacheable(true).list();
    if ( dialectIsCaseSensitive("i.name='widget' should not match on case sensitive database.") ) {
        assertEquals( result.size(), 0 );
    }
    i = (Item) s.get( Item.class, new Long(i.getId()) );
    assertEquals( i.getName(), "Widget" );

    s.delete(i);
    t.commit();
    s.close();

    assertEquals( qs.getCacheHitCount(), 2 );
    assertEquals( qs.getCacheMissCount(), 3 );
    assertEquals( qs.getCachePutCount(), 3 );
    assertEquals( qs.getExecutionCount(), 3 );
    assertEquals( es.getFetchCount(), 0 ); //check that it was being cached

}
项目:HibernateStatistics    文件:DelegatingStatisticsService.java   
public EntityStatistics getEntityStatistics(String arg0) {
    return delegate.getEntityStatistics( arg0 );
}
项目:spring-advanced-training    文件:StatServiceImpl.java   
@Override
public EntityStatistics getEntityStatistics(String entityName) {
    return getStatistics().getEntityStatistics("com.github.aha.sat.rest.domain." + entityName);
}
项目:spring-advanced-training    文件:StatController.java   
@RequestMapping(value = "/entity/{entity}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@ApiOperation(value = "Returns statistics of the entity", response = EntityStatistics.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of entity statistics") })
public EntityStatistics entityStat(@PathVariable String entity) {
    return statService.getEntityStatistics(entity);
}
项目:spring-advanced-training    文件:StatService.java   
EntityStatistics getEntityStatistics(String entityName);