本文整理了Java中org.hibernate.stat.Statistics.getQueries()
方法的一些代码示例,展示了Statistics.getQueries()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statistics.getQueries()
方法的具体详情如下:
包路径:org.hibernate.stat.Statistics
类名称:Statistics
方法名:getQueries
[英]Get all executed query strings. The maximum number of queries tracked by the Hibernate statistics is given by the hibernate.statistics.query_max_size property.
[中]获取所有执行的查询字符串。Hibernate统计信息跟踪的最大查询数由Hibernate提供。统计数字查询_max_size属性。
代码示例来源:origin: wildfly/wildfly
@Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
Set<String> result = new HashSet<>();
org.hibernate.stat.Statistics stats = getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL)));
if (stats != null) {
String[] queries = stats.getQueries();
if (queries != null) {
for (String query : queries) {
result.add(QueryName.queryName(query).getDisplayName());
}
}
}
return result;
}
代码示例来源:origin: wildfly/wildfly
@Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
Set<String> result = new HashSet<>();
org.hibernate.stat.Statistics stats = getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL)));
if (stats != null) {
String[] queries = stats.getQueries();
if (queries != null) {
for (String query : queries) {
result.add(QueryName.queryName(query).getDisplayName());
}
}
}
return result;
}
代码示例来源:origin: wildfly/wildfly
@Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
Set<String> result = new HashSet<>();
org.hibernate.stat.Statistics stats = getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL)));
if (stats != null) {
String[] queries = stats.getQueries();
if (queries != null) {
for (String query : queries) {
result.add(QueryName.queryName(query).getDisplayName());
}
}
}
return result;
}
代码示例来源:origin: wildfly/wildfly
@Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
Set<String> result = new HashSet<>();
org.hibernate.stat.Statistics stats = getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL)));
if (stats != null) {
String[] queries = stats.getQueries();
if (queries != null) {
for (String query : queries) {
result.add(QueryName.queryName(query).getDisplayName());
}
}
}
return result;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Collection<String> getDynamicChildrenNames(
EntityManagerFactoryAccess entityManagerFactoryLookup,
PathAddress pathAddress) {
Set<String> result = new HashSet<>();
org.hibernate.stat.Statistics stats = getBaseStatistics( entityManagerFactoryLookup.entityManagerFactory(
pathAddress.getValue( HibernateStatistics.PROVIDER_LABEL ) ) );
if ( stats != null ) {
String[] queries = stats.getQueries();
if ( queries != null ) {
for ( String query : queries ) {
result.add( QueryName.queryName( query ).getDisplayName() );
}
}
}
return result;
}
代码示例来源:origin: gocd/gocd
json.put("Queries", queryStats);
String[] queries = statistics.getQueries();
for (String query : queries) {
queryStats.put(query, statistics.getQueryStatistics(query));
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Object invoke(Object... args) {
String displayQueryName = getQueryName( args );
EntityManagerFactory entityManagerFactory = getEntityManagerFactory( args );
if ( displayQueryName != null && entityManagerFactory != null ) {
SessionFactory sessionFactory = entityManagerFactory.unwrap( SessionFactory.class );
// convert displayed (transformed by QueryNames) query name to original query name
if ( sessionFactory != null ) {
String[] originalQueryNames = sessionFactory.getStatistics().getQueries();
if ( originalQueryNames != null ) {
for ( String originalQueryName : originalQueryNames ) {
if ( QueryName.queryName( originalQueryName )
.getDisplayName()
.equals( displayQueryName ) ) {
return originalQueryName;
}
}
}
}
}
return null;
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public Object invoke(Object... args) {
String displayQueryName = getQueryName(args);
EntityManagerFactory entityManagerFactory = getEntityManagerFactory(args);
if (displayQueryName != null && entityManagerFactory != null) {
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
// convert displayed (transformed by QueryNames) query name to original query name
if (sessionFactory != null) {
String[] originalQueryNames = sessionFactory.getStatistics().getQueries();
if (originalQueryNames != null) {
for (String originalQueryName : originalQueryNames) {
if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) {
return originalQueryName;
}
}
}
}
}
return null;
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public Object invoke(Object... args) {
String displayQueryName = getQueryName(args);
EntityManagerFactory entityManagerFactory = getEntityManagerFactory(args);
if (displayQueryName != null && entityManagerFactory != null) {
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
// convert displayed (transformed by QueryNames) query name to original query name
if (sessionFactory != null) {
String[] originalQueryNames = sessionFactory.getStatistics().getQueries();
if (originalQueryNames != null) {
for (String originalQueryName : originalQueryNames) {
if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) {
return originalQueryName;
}
}
}
}
}
return null;
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public Object invoke(Object... args) {
String displayQueryName = getQueryName(args);
EntityManagerFactory entityManagerFactory = getEntityManagerFactory(args);
if (displayQueryName != null && entityManagerFactory != null) {
HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory;
SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory();
// convert displayed (transformed by QueryNames) query name to original query name
if (sessionFactory != null) {
String[] originalQueryNames = sessionFactory.getStatistics().getQueries();
if (originalQueryNames != null) {
for (String originalQueryName : originalQueryNames) {
if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) {
return originalQueryName;
}
}
}
}
}
return null;
}
};
代码示例来源: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
@Test
public void testFiltersAreApplied() {
doInHibernate( this::sessionFactory, session -> {
session.enableFilter( "ID" ).setParameter( "id", 3L );
List result = session.createQuery( "from Customer order by id" ).list();
assertFalse( result.isEmpty() );
Customer customer = (Customer) result.get( 0 );
assertSame( customer.getCustomerId(), 3L );
assertSame( customer.getOrders().size(), 2 );
SessionStatistics statistics = session.getStatistics();
assertSame( statistics.getEntityCount(), 9 );
Statistics sfStatistics = session.getSessionFactory().getStatistics();
assertSame( sfStatistics.getCollectionFetchCount(), 1L );
assertSame( sfStatistics.getQueries().length, 1 );
} );
}
代码示例来源:origin: prometheus/client_java
private void addMetricsForQuery(PerQuerySamples samples, ValueProviderPerQuery provider) {
for (Entry<String, SessionFactory> entry : sessionFactories.entrySet()) {
SessionFactory sessionFactory = entry.getValue();
Statistics stats = sessionFactory.getStatistics();
String unitName = entry.getKey();
for (String query : stats.getQueries()) {
samples.addMetric(Arrays.asList(unitName, query), provider.getValue(stats, query));
}
}
}
代码示例来源: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.jipijapa/jipijapa-hibernate4-3
@Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
Set<String> result = new HashSet<String>();
String[] queries = getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getQueries();
if (queries != null) {
for (String query : queries) {
result.add(QueryName.queryName(query).getDisplayName());
}
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!