org.hibernate.stat.Statistics#getCollectionFetchCount ( )源码实例Demo

下面列出了org.hibernate.stat.Statistics#getCollectionFetchCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: HibernateTips   文件: TestStatistics.java
@Test
public void statisticsAPI() {
	log.info("... statisticsAPI ...");

	EntityManager em = emf.createEntityManager();
	em.getTransaction().begin();

	List<Author> authors = em.createQuery("SELECT a FROM Author a", Author.class).getResultList();

	for (Author a : authors) {
		log.info(a.getFirstName() + " " + a.getLastName() + " wrote " + a.getBooks().size());
	}
	
	SessionFactory sessionFactory = emf.unwrap(SessionFactory.class);
	Statistics stats = sessionFactory.getStatistics();
	long queryCount = stats.getQueryExecutionCount();
	long collectionFetchCount = stats.getCollectionFetchCount();
	log.info("QueryCount: "+queryCount);
	log.info("CollectionFetchCount: "+collectionFetchCount);
	
	em.getTransaction().commit();
	em.close();
}
 
源代码2 项目: quarkus   文件: HibernateCounter.java
@Override
public long getCount() {
    Statistics statistics = getSessionFactory().getStatistics();
    switch (metric) {
        case "sessionsOpened":
            return statistics.getSessionOpenCount();
        case "sessionsClosed":
            return statistics.getSessionCloseCount();
        case "transactionCount":
            return statistics.getTransactionCount();
        case "successfulTransactions":
            return statistics.getSuccessfulTransactionCount();
        case "optimisticLockFailures":
            return statistics.getOptimisticFailureCount();
        case "flushes":
            return statistics.getFlushCount();
        case "connectionsObtained":
            return statistics.getConnectCount();
        case "statementsPrepared":
            return statistics.getPrepareStatementCount();
        case "statementsClosed":
            return statistics.getCloseStatementCount();
        case "secondLevelCachePuts":
            return statistics.getSecondLevelCachePutCount();
        case "secondLevelCacheHits":
            return statistics.getSecondLevelCacheHitCount();
        case "secondLevelCacheMisses":
            return statistics.getSecondLevelCacheMissCount();
        case "entitiesLoaded":
            return statistics.getEntityLoadCount();
        case "entitiesUpdated":
            return statistics.getEntityUpdateCount();
        case "entitiesInserted":
            return statistics.getEntityInsertCount();
        case "entitiesDeleted":
            return statistics.getEntityDeleteCount();
        case "entitiesFetched":
            return statistics.getEntityFetchCount();
        case "collectionsLoaded":
            return statistics.getCollectionLoadCount();
        case "collectionsUpdated":
            return statistics.getCollectionUpdateCount();
        case "collectionsRemoved":
            return statistics.getCollectionRemoveCount();
        case "collectionsRecreated":
            return statistics.getCollectionRecreateCount();
        case "collectionsFetched":
            return statistics.getCollectionFetchCount();
        case "naturalIdQueriesExecutedToDatabase":
            return statistics.getNaturalIdQueryExecutionCount();
        case "naturalIdCachePuts":
            return statistics.getNaturalIdCachePutCount();
        case "naturalIdCacheHits":
            return statistics.getNaturalIdCacheHitCount();
        case "naturalIdCacheMisses":
            return statistics.getNaturalIdCacheMissCount();
        case "queriesExecutedToDatabase":
            return statistics.getQueryExecutionCount();
        case "queryCachePuts":
            return statistics.getQueryCachePutCount();
        case "queryCacheHits":
            return statistics.getQueryCacheHitCount();
        case "queryCacheMisses":
            return statistics.getQueryCacheMissCount();
        case "updateTimestampsCachePuts":
            return statistics.getUpdateTimestampsCachePutCount();
        case "updateTimestampsCacheHits":
            return statistics.getUpdateTimestampsCacheHitCount();
        case "updateTimestampsCacheMisses":
            return statistics.getUpdateTimestampsCacheMissCount();
        default:
            throw new IllegalArgumentException("Unknown data source metric");
    }
}