// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java
// public interface EntityManagerFactoryAccess {
//     /**
//      * returns the entity manager factory that statistics should be obtained for.
//      *
//      * @throws IllegalStateException if scopedPersistenceUnitName is not found
//      *
//      * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform
//      *
//      * @return EntityManagerFactory
//      */
//     EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException;
// 
// }
// 
// Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java
// public interface Operation {
// 
//     /**
//      * Invoke operation
//      * @param args will be passed to invoked operation
//      * @return
//      */
//     Object invoke(Object... args);
// }
// 
// Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java
// public interface PathAddress {
// 
//     int size();
// 
//     String getValue(String name);
//     String getValue(int index);
// }


import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.EntityManagerFactory;
import org.hibernate.SessionFactory;
import org.hibernate.jpa.HibernateEntityManagerFactory;
import org.jipijapa.management.spi.EntityManagerFactoryAccess;
import org.jipijapa.management.spi.Operation;
import org.jipijapa.management.spi.PathAddress;
        }
        return result;
    }

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

    private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) {
        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;
    }

// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java
// public interface EntityManagerFactoryAccess {
//     /**
//      * returns the entity manager factory that statistics should be obtained for.
//      *
//      * @throws IllegalStateException if scopedPersistenceUnitName is not found
//      *
//      * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform
//      *
//      * @return EntityManagerFactory
//      */
//     EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException;
// 
// }
// 
// Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java
// public interface Operation {
// 
//     /**
//      * Invoke operation
//      * @param args will be passed to invoked operation
//      * @return
//      */
//     Object invoke(Object... args);
// }
// 
// Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java
// public interface PathAddress {
// 
//     int size();
// 
//     String getValue(String name);
//     String getValue(int index);
// }


// Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.EntityManagerFactory;
import org.hibernate.SessionFactory;
import org.hibernate.jpa.HibernateEntityManagerFactory;
import org.jipijapa.management.spi.EntityManagerFactoryAccess;
import org.jipijapa.management.spi.Operation;
import org.jipijapa.management.spi.PathAddress;

        }
        return result;
    }

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

    private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) {
        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;
    }

    private Operation queryExecutionCount = new Operation() {