本文整理汇总了Java中org.hibernate.stat.SessionStatistics类的典型用法代码示例。如果您正苦于以下问题:Java SessionStatistics类的具体用法?Java SessionStatistics怎么用?Java SessionStatistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionStatistics类属于org.hibernate.stat包,在下文中一共展示了SessionStatistics类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flush
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
/**
* Flushes the current state to the database.
*/
public void flush() {
if (SessionHandler.isSessionHandlerPresent()) {
long s1 = System.currentTimeMillis();
SessionHandler.getInstance().getSession().flush();
if (log.isDebugEnabled()) {
long s2 = System.currentTimeMillis();
SessionStatistics sessStat = SessionHandler.getInstance().getSession().getStatistics();
dumpSessionEntities();
log.debug(
"Flush of " + sessStat.getEntityCount() + " entities and "
+ sessStat.getCollectionCount() + " collections took: " + (s2 - s1),
new Throwable());
}
}
}
示例2: dumpSessionEntities
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
/**
* Utility method to log all entities loaded into the current hibernate session. Useful to debug
* slow flush() calls.
*/
private void dumpSessionEntities() {
SessionStatistics sessStat = SessionHandler.getInstance().getSession().getStatistics();
log.debug("Dumping all entities in session");
for (Object o : sessStat.getEntityKeys()) {
log.debug(o);
}
}
示例3: dalObjectLoaded
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean dalObjectLoaded(String entityName, String id) {
SessionStatistics stats = SessionHandler.getInstance().getSession().getStatistics();
for (EntityKey k : (Set<EntityKey>) stats.getEntityKeys()) {
if (entityName.equals(k.getEntityName()) && id.equals(k.getIdentifier())) {
return true;
}
}
return false;
}
示例4: testSessionStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
public void testSessionStatistics() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Statistics stats = getSessions().getStatistics();
stats.clear();
boolean isStats = stats.isStatisticsEnabled();
stats.setStatisticsEnabled(true);
Continent europe = fillDb(s);
tx.commit();
s.clear();
tx = s.beginTransaction();
SessionStatistics sessionStats = s.getStatistics();
assertEquals( 0, sessionStats.getEntityKeys().size() );
assertEquals( 0, sessionStats.getEntityCount() );
assertEquals( 0, sessionStats.getCollectionKeys().size() );
assertEquals( 0, sessionStats.getCollectionCount() );
europe = (Continent) s.get( Continent.class, europe.getId() );
Hibernate.initialize( europe.getCountries() );
Hibernate.initialize( europe.getCountries().iterator().next() );
assertEquals( 2, sessionStats.getEntityKeys().size() );
assertEquals( 2, sessionStats.getEntityCount() );
assertEquals( 1, sessionStats.getCollectionKeys().size() );
assertEquals( 1, sessionStats.getCollectionCount() );
tx.commit();
s.close();
stats.setStatisticsEnabled( isStats);
}
示例5: getStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
@Override
public SessionStatistics getStatistics() {
return session.getStatistics();
}
示例6: getStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
@Override
public SessionStatistics getStatistics() {
checkTransactionSynchStatus();
return new SessionStatisticsImpl(this);
}
示例7: getStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
public SessionStatistics getStatistics() {
checkTransactionSynchStatus();
return new SessionStatisticsImpl(this);
}
示例8: getStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
/**
* Get the statistics for this session.
*
* @return The session statistics being collected for this session
*/
public SessionStatistics getStatistics();
示例9: getStatistics
import org.hibernate.stat.SessionStatistics; //导入依赖的package包/类
/**
* Get the statistics for this session.
*/
public SessionStatistics getStatistics();