org.hibernate.stat.Statistics.isStatisticsEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.hibernate.stat.Statistics.isStatisticsEnabled()方法的一些代码示例,展示了Statistics.isStatisticsEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statistics.isStatisticsEnabled()方法的具体详情如下:
包路径:org.hibernate.stat.Statistics
类名称:Statistics
方法名:isStatisticsEnabled

Statistics.isStatisticsEnabled介绍

[英]Are statistics enabled
[中]是否启用了统计信息

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
  public Object invoke(Object... args) {
    org.hibernate.stat.Statistics statistics = getStatistics( getEntityManagerFactory( args ) );
    if ( statistics != null ) {
      if ( args.length > 0 && args[0] instanceof Boolean ) {
        Boolean newValue = (Boolean) args[0];
        statistics.setStatisticsEnabled( newValue.booleanValue() );
      }
      return Boolean.valueOf( statistics.isStatisticsEnabled() );
    }
    return null;
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public Object invoke(Object... args) {
    org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args));
    if (statistics != null) {
      if (args.length > 0 && args[0] instanceof Boolean) {
        Boolean newValue = (Boolean) args[0];
        statistics.setStatisticsEnabled(newValue.booleanValue());
      }
    return Boolean.valueOf(statistics.isStatisticsEnabled());
    }
   return null;
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public Object invoke(Object... args) {
    org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args));
    if (statistics != null) {
      if (args.length > 0 && args[0] instanceof Boolean) {
        Boolean newValue = (Boolean) args[0];
        statistics.setStatisticsEnabled(newValue.booleanValue());
      }
    return Boolean.valueOf(statistics.isStatisticsEnabled());
    }
   return null;
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public Object invoke(Object... args) {
    org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args));
    if (statistics != null) {
      if (args.length > 0 && args[0] instanceof Boolean) {
        Boolean newValue = (Boolean) args[0];
        statistics.setStatisticsEnabled(newValue.booleanValue());
      }
    return Boolean.valueOf(statistics.isStatisticsEnabled());
    }
   return null;
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public Object invoke(Object... args) {
    org.hibernate.stat.Statistics statistics = getStatistics(getEntityManagerFactory(args));
    if (statistics != null) {
      if (args.length > 0 && args[0] instanceof Boolean) {
        Boolean newValue = (Boolean) args[0];
        statistics.setStatisticsEnabled(newValue.booleanValue());
      }
    return Boolean.valueOf(statistics.isStatisticsEnabled());
    }
   return null;
  }
};

代码示例来源:origin: gocd/gocd

LinkedHashMap<String, Object> json = new LinkedHashMap<>();
Statistics statistics = sessionFactory.getStatistics();
if (!statistics.isStatisticsEnabled()){
  return json;

代码示例来源:origin: hibernate/hibernate-orm

@TestForIssue(jiraKey = "HHH-4838")
@Test
public void testNaturalKeyLookupWithConstraint() {
  Session s = openSession();
  Transaction newTx = s.getTransaction();
  newTx.begin();
  A a1 = new A();
  a1.setName( "name1" );
  s.persist( a1 );
  newTx.commit();
  newTx = s.beginTransaction();
  getCriteria( s ).add( Restrictions.isNull( "singleD" ) ).uniqueResult(); // put query-result into cache
  A a2 = new A();
  a2.setName( "xxxxxx" );
  s.persist( a2 );
  newTx.commit();      // Invalidates space A in UpdateTimeStamps region
  newTx = s.beginTransaction();
  Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
  s.getSessionFactory().getStatistics().clear();
  // should not produce a hit in StandardQuery cache region because there is a constraint
  getCriteria( s ).add( Restrictions.isNull( "singleD" ) ).uniqueResult();
  Assert.assertEquals( 0, s.getSessionFactory().getStatistics().getQueryCacheHitCount() );
  s.createQuery( "delete from A" ).executeUpdate();
  newTx.commit();
  // Shutting down the application
  s.close();
}

代码示例来源:origin: hibernate/hibernate-orm

Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
s.getSessionFactory().getStatistics().clear();

代码示例来源:origin: hibernate/hibernate-orm

Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
s.getSessionFactory().getStatistics().clear();

代码示例来源:origin: hibernate/hibernate-orm

Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
s.getSessionFactory().getStatistics().clear();

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * {@inheritDoc}
 * 
 * @see net.sf.ehcache.hibernate.management.api.HibernateStats#isStatisticsEnabled()
 */
public boolean isStatisticsEnabled() {
  return getStatistics().isStatisticsEnabled();
}

代码示例来源:origin: hibernate/hibernate-orm

Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
s.getSessionFactory().getStatistics().clear();

代码示例来源:origin: hibernate/hibernate-orm

Assert.assertTrue( s.getSessionFactory().getStatistics().isStatisticsEnabled() );
s.getSessionFactory().getStatistics().clear();

代码示例来源: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: jboss.jboss-embeddable-ejb3/hibernate-all

/**
 * @see StatisticsServiceMBean#isStatisticsEnabled()
 */
public boolean isStatisticsEnabled() {
  return stats.isStatisticsEnabled();
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * {@inheritDoc}
 * 
 * @see net.sf.ehcache.hibernate.management.api.HibernateStats#isStatisticsEnabled()
 */
public boolean isStatisticsEnabled() {
  return getStatistics().isStatisticsEnabled();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

@Override
public void physicalConnectionObtained(Connection connection) {
  if (sessionFactory.getStatistics().isStatisticsEnabled()) {
    sessionFactory.getStatisticsImplementor().connect();
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public void physicalConnectionObtained(Connection connection) {
  if (sessionFactory.getStatistics().isStatisticsEnabled()) {
    sessionFactory.getStatisticsImplementor().connect();
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

@Override
  public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
    final boolean put = naturalIdCacheAccessStrategy.afterUpdate( naturalIdCacheKey, pk, lock );
    if ( put && factory.getStatistics().isStatisticsEnabled() ) {
      factory.getStatisticsImplementor().naturalIdCachePut(
          naturalIdCacheAccessStrategy.getRegion().getName() );
    }
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

@Override
  public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
    final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, pk );
    if ( put && factory.getStatistics().isStatisticsEnabled() ) {
      factory.getStatisticsImplementor().naturalIdCachePut(
          naturalIdCacheAccessStrategy.getRegion().getName() );
    }
  }
}

相关文章

Statistics类方法