Search in sources :

Example 11 with HibernateEntityManagerFactory

use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.

the class HibernateEntityCacheStatistics method getBaseStatistics.

private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) {
    if (entityManagerFactory == null) {
        return null;
    }
    HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
    SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
    if (sessionFactory != null) {
        return sessionFactory.getStatistics();
    }
    return null;
}
Also used : SessionFactory(org.hibernate.SessionFactory) HibernateEntityManagerFactory(org.hibernate.jpa.HibernateEntityManagerFactory)

Example 12 with HibernateEntityManagerFactory

use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.

the class HibernateEntityStatistics method getBaseStatistics.

private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) {
    if (entityManagerFactory == null) {
        return null;
    }
    HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
    SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
    if (sessionFactory != null) {
        return sessionFactory.getStatistics();
    }
    return null;
}
Also used : SessionFactory(org.hibernate.SessionFactory) HibernateEntityManagerFactory(org.hibernate.jpa.HibernateEntityManagerFactory)

Example 13 with HibernateEntityManagerFactory

use of org.hibernate.jpa.HibernateEntityManagerFactory in project wildfly by wildfly.

the class HibernateQueryCacheStatistics method getStatistics.

private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) {
    if (entityManagerFactory == null) {
        return null;
    }
    HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
    SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
    // convert displayed (transformed by QueryNames) query name to original query name to look up query statistics
    if (sessionFactory != null) {
        String[] originalQueryNames = sessionFactory.getStatistics().getQueries();
        if (originalQueryNames != null) {
            for (String originalQueryName : originalQueryNames) {
                if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) {
                    return sessionFactory.getStatistics().getQueryStatistics(originalQueryName);
                }
            }
        }
    }
    return null;
}
Also used : SessionFactory(org.hibernate.SessionFactory) HibernateEntityManagerFactory(org.hibernate.jpa.HibernateEntityManagerFactory)

Aggregations

HibernateEntityManagerFactory (org.hibernate.jpa.HibernateEntityManagerFactory)13 SessionFactory (org.hibernate.SessionFactory)9 Test (org.junit.Test)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EntityManager (javax.persistence.EntityManager)1 EntityManagerFactoryBuilder (org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder)1 BaseEntityManagerFunctionalTestCase (org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase)1 Statistics (org.hibernate.stat.Statistics)1 TestForIssue (org.hibernate.testing.TestForIssue)1