本文整理了Java中org.hibernate.stat.Statistics.getQueryStatistics()
方法的一些代码示例,展示了Statistics.getQueryStatistics()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statistics.getQueryStatistics()
方法的具体详情如下:
包路径:org.hibernate.stat.Statistics
类名称:Statistics
方法名:getQueryStatistics
[英]Query statistics from query string (HQL or SQL)
[中]来自查询字符串(HQL或SQL)的查询统计信息
代码示例来源:origin: gocd/gocd
queryStats.put(query, statistics.getQueryStatistics(query));
代码示例来源:origin: hibernate/hibernate-orm
private org.hibernate.stat.QueryStatistics getStatistics(
EntityManagerFactory entityManagerFactory,
String displayQueryName) {
if ( entityManagerFactory == null ) {
return null;
}
SessionFactory sessionFactory = entityManagerFactory.unwrap( SessionFactory.class );
// 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;
}
代码示例来源:origin: wildfly/wildfly
private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) {
if (entityManagerFactory == null) {
return null;
}
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
// 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;
}
代码示例来源:origin: wildfly/wildfly
private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) {
if (entityManagerFactory == null) {
return null;
}
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
// 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;
}
代码示例来源:origin: wildfly/wildfly
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;
}
代码示例来源:origin: wildfly/wildfly
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;
}
代码示例来源:origin: hibernate/hibernate-orm
private void assertQueryStatistics(String hql, int hitCount) {
QueryStatistics queryStatistics = statistics.getQueryStatistics( hql );
assertEquals( hitCount, queryStatistics.getPlanCacheHitCount() );
assertEquals( 1, queryStatistics.getPlanCacheMissCount() );
assertTrue( queryStatistics.getPlanCompilationTotalMicroseconds() > 0 );
}
代码示例来源:origin: hibernate/hibernate-orm
final String continents = "from Continent";
int results = s.createQuery( continents ).list().size();
QueryStatistics continentStats = sf.getStatistics().getQueryStatistics( continents );
assertNotNull( "stats were null", continentStats );
assertEquals( "unexpected execution count", 1, continentStats.getExecutionCount() );
final String localities = "from Locality";
results = s.createQuery( localities ).list().size();
QueryStatistics localityStats = sf.getStatistics().getQueryStatistics( localities );
assertNotNull( "stats were null", localityStats );
final String sql = "select id, name from Country";
results = s.createSQLQuery( sql ).addEntity( Country.class ).list().size();
QueryStatistics sqlStats = sf.getStatistics().getQueryStatistics( sql );
assertNotNull( "sql stats were null", sqlStats );
assertEquals( "unexpected execution count", 1, sqlStats.getExecutionCount() );
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return statistics.getQueryStatistics(query)
.getExecutionRowCount();
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return toSeconds(statistics.getQueryStatistics(query)
.getExecutionMinTime());
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return statistics.getQueryStatistics(query)
.getCacheHitCount();
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return statistics.getQueryStatistics(query)
.getCacheMissCount();
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return statistics.getQueryStatistics(query)
.getExecutionCount();
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return statistics.getQueryStatistics(query)
.getCachePutCount();
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return toSeconds(statistics.getQueryStatistics(query)
.getExecutionMaxTime());
}
}
代码示例来源:origin: prometheus/client_java
@Override
public double getValue(Statistics statistics, String query) {
return toSeconds(statistics.getQueryStatistics(query)
.getExecutionTotalTime());
}
}
代码示例来源:origin: hibernate/hibernate-orm
QueryStatistics queryStats = stats.getQueryStatistics( "from Event" );
assertThat( "Cache Miss Count", queryStats.getCacheMissCount(), equalTo( 1L ) );
assertThat( "Cache Hit Count", queryStats.getCacheHitCount(), equalTo( 0L ) );
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
*
* @see net.sf.ehcache.hibernate.management.api.HibernateStats#getQueryStats()
*/
public TabularData getQueryStats() {
List<CompositeData> result = new ArrayList<CompositeData>();
Statistics statistics = getStatistics();
for (String query : statistics.getQueries()) {
QueryStats queryStats = new QueryStats(query, statistics.getQueryStatistics(query));
result.add(queryStats.toCompositeData());
}
TabularData td = QueryStats.newTabularDataInstance();
td.putAll(result.toArray(new CompositeData[result.size()]));
return td;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* Convenience method to print out the hibernate cache usage stats to the log
*/
private void showUsageStatistics() {
if (sessionFactory.getStatistics().isStatisticsEnabled()) {
log.debug("Getting query statistics: ");
Statistics stats = sessionFactory.getStatistics();
for (String query : stats.getQueries()) {
log.info("QUERY: " + query);
QueryStatistics qstats = stats.getQueryStatistics(query);
log.info("Cache Hit Count : " + qstats.getCacheHitCount());
log.info("Cache Miss Count: " + qstats.getCacheMissCount());
log.info("Cache Put Count : " + qstats.getCachePutCount());
log.info("Execution Count : " + qstats.getExecutionCount());
log.info("Average time : " + qstats.getExecutionAvgTime());
log.info("Row Count : " + qstats.getExecutionRowCount());
}
}
}
代码示例来源:origin: org.apache.tapestry/tapestry-hibernate
public QueryStatistics getQueryStatistics()
{
return getStatistics().getQueryStatistics(currentQuery);
}
内容来源于网络,如有侵权,请联系作者删除!