Package org.hibernate.stat

Examples of org.hibernate.stat.Statistics


   * @param id Employee's id in the query
   */
  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);
         
      String queryString = "from Employee e where e.id > "+id;
      QueryStatistics queryStats = stats.getQueryStatistics(queryString);
      Query query = em.createQuery(queryString);
      query.setHint("org.hibernate.cacheable", true);

      // query - this call should fill the cache
      query.getResultList();
View Full Code Here


        return new HibernateStatisticsResource(puName, persistenceUnitRegistry, providerLabel);
    }

    private boolean hasEntity(PathElement element) {
        boolean result = false;
        final Statistics stats = getStatistics();
        if (stats != null) {
            final String entityName = element.getValue();
            result = stats.getEntityStatistics(entityName) != null;
        }
        return result;
    }
View Full Code Here

        }
        return result;
    }

    private Set<String> getEntityNames() {
        final Statistics stats = getStatistics();
        if (stats == null) {
            return Collections.emptySet();
        } else {
            Set<String> result = new HashSet<String>();
            String[] entityNames = stats.getEntityNames();
            if (entityNames != null) {
                for (String entity : entityNames) {
                    result.add(entity);
                }
            }
View Full Code Here

    }

    private boolean hasCacheRegion(PathElement element) {
        boolean result = false;
        final PersistenceUnitService puService = persistenceUnitRegistry.getPersistenceUnitService(puName);
        final Statistics stats = getStatistics();
        if (stats != null && puService != null) {
            final String scopedPUName = puService.getScopedPersistenceUnitName();
            final String unqualifiedRegionName = element.getValue();
            final String qualifiedRegionName = scopedPUName + "." + unqualifiedRegionName;
            result = stats.getSecondLevelCacheStatistics(qualifiedRegionName) != null;
        }
        return result;
    }
View Full Code Here

        }
        return result;
    }

    private Set<String> getCacheRegionNames() {
        final Statistics stats = getStatistics();
        if (stats == null) {
            return Collections.emptySet();
        } else {
            Set<String> result = new HashSet<String>();
            String[] cacheRegionNames = stats.getSecondLevelCacheRegionNames();
            if (cacheRegionNames != null) {
                for (String region : cacheRegionNames) {

                    // example regionName = "jpa_SecondLevelCacheTestCase.jar#mypc.org.jboss.as.test.integration.jpa.hibernate.Employee"
                    // remove the scoped PU name plus one for '.' the separator character added to it.
View Full Code Here

    }

    private boolean hasQuery(PathElement element) {
        boolean result = false;
        final PersistenceUnitService puService = persistenceUnitRegistry.getPersistenceUnitService(puName);
        final Statistics stats = getStatistics();
        if (stats != null && puService != null) {
            final String scopedPUName = puService.getScopedPersistenceUnitName();
            final String unqualifiedQueryName = element.getValue();
            final String queryName = scopedPUName + "." + unqualifiedQueryName;
            result = stats.getQueryStatistics(queryName) != null;
        }
        return result;
    }
View Full Code Here

        return result;
    }


    private Set<String> getQueryNames() {
        final Statistics stats = getStatistics();
        if (stats == null) {
            return Collections.emptySet();
        } else {
            Set<String> result = new HashSet<String>();
            String[] queries = stats.getQueries();
            if (queries != null) {
                for (String query : queries) {
                    result.add(QueryName.queryName(query).getDisplayName());
                }
            }
View Full Code Here

        }
    }

    private boolean hasCollection(PathElement element) {
        boolean result = false;
        final Statistics stats = getStatistics();
        if (stats != null) {
            final String collectionName = element.getValue();
            result = stats.getCollectionStatistics(collectionName) != null;
        }
        return result;
    }
View Full Code Here

        }
        return result;
    }

    private Set<String> getCollectionNames() {
        final Statistics stats = getStatistics();
        if (stats == null) {
            return Collections.emptySet();
        } else {
            Set<String> result = new HashSet<String>();
            String[] collectionNames = stats.getCollectionRoleNames();
            if (collectionNames != null) {
                for (String entity : collectionNames) {
                    result.add(entity);
                }
            }
View Full Code Here

        return new HibernateStatisticsResource(puName, persistenceUnitRegistry, providerLabel);
    }

    private boolean hasEntity(PathElement element) {
        boolean result = false;
        final Statistics stats = getStatistics();
        if (stats != null) {
            final String emtityName = element.getValue();
            result = stats.getEntityStatistics(emtityName) != null;
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.stat.Statistics

Copyright © 2018 www.massapicom. 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.