private SessionImpl(SessionImpl parent, EntityMode entityMode) { this.factory = parent.factory; this.timestamp = parent.timestamp; this.jdbcContext = parent.jdbcContext; this.interceptor = parent.interceptor; this.listeners = parent.listeners; this.actionQueue = new ActionQueue(this); this.entityMode = entityMode; this.persistenceContext = new PersistenceContext(this); this.flushBeforeCompletionEnabled = false; this.autoCloseSessionEnabled = false; this.connectionReleaseMode = null; this.isRootSession = false; if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession(); } log.debug( "opened session [" + entityMode + "]" ); }
public Object put(final Object key, final Object value) { Object cache = null; if (value instanceof HibernateCacheInstanceRetriever) { cache = ((HibernateCacheInstanceRetriever) value).retrieveHibernateCacheInstance(); } boolean registeredCacheWithMBean = false; if (cache != null && cache instanceof TerracottaHibernateCache) { final Statistics stats = sessionFactory.getStatistics(); if (stats instanceof HibernateStatsBeanAware) { ((HibernateStatsBeanAware) stats).__tc_getMBean().addTerracottaHibernateCache((String) key, (TerracottaHibernateCache) cache); registeredCacheWithMBean = true; } } if (!registeredCacheWithMBean) { LOGGER.warn("Couldn't retrieve cache instance from '" + value + "' to register it with the Terracotta Hibernate statistics MBean."); } return delegate.put(key, value); }
/** * Constructor used in building "child sessions". * * @param parent The parent session * @param entityMode */ private SessionImpl(SessionImpl parent, EntityMode entityMode) { super( parent.factory ); this.rootSession = parent; this.timestamp = parent.timestamp; this.jdbcContext = parent.jdbcContext; this.interceptor = parent.interceptor; this.listeners = parent.listeners; this.actionQueue = new ActionQueue( this ); this.entityMode = entityMode; this.persistenceContext = new StatefulPersistenceContext( this ); this.flushBeforeCompletionEnabled = false; this.autoCloseSessionEnabled = false; this.connectionReleaseMode = null; if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession(); } log.debug( "opened session [" + entityMode + "]" ); }
getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() );
public Connection close() throws HibernateException { log.trace( "closing session" ); if ( factory.getStatistics().isStatisticsEnabled() ) factory.getStatisticsImplementor().closeSession(); try { try { if ( childSessionsByEntityMode != null ) { Iterator childSessions = childSessionsByEntityMode.values().iterator(); while ( childSessions.hasNext() ) { final SessionImpl child = ( SessionImpl ) childSessions.next(); child.close(); } } } catch( Throwable t ) { // just ignore } if ( isRootSession ) { return jdbcContext.getConnectionManager().close(); } else { return null; } } finally { closed = true; cleanup(); } }
getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() );
if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().closeSession();
if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession();
this.jdbcContext = new JDBCContext( this, connection, interceptor ); if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession();