本文整理匯總了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();