/** * Closes the session factory, releasing all held resources. * * <ol> * <li>cleans up used cache regions and "stops" the cache provider. * <li>close the JDBC connection * <li>remove the JNDI binding * </ol> * * Note: Be aware that the sessionfactory instance still can be a "heavy" object memory wise after * close() has been called. Thus it is important to not keep referencing the instance to let the * garbage collector release the memory. */ public void close() throws HibernateException { if (isClosed) { log.trace("already closed"); return; } log.info("closing"); isClosed = true; Iterator iter = entityPersisters.values().iterator(); while (iter.hasNext()) { EntityPersister p = (EntityPersister) iter.next(); if (p.hasCache()) { p.getCacheAccessStrategy().getRegion().destroy(); } } iter = collectionPersisters.values().iterator(); while (iter.hasNext()) { CollectionPersister p = (CollectionPersister) iter.next(); if (p.hasCache()) { p.getCacheAccessStrategy().getRegion().destroy(); } } if (settings.isQueryCacheEnabled()) { queryCache.destroy(); iter = queryCaches.values().iterator(); while (iter.hasNext()) { QueryCache cache = (QueryCache) iter.next(); cache.destroy(); } updateTimestampsCache.destroy(); } settings.getRegionFactory().stop(); if (settings.isAutoDropSchema()) { schemaExport.drop(false, true); } try { settings.getConnectionProvider().close(); } finally { SessionFactoryObjectFactory.removeInstance(uuid, name, properties); } observer.sessionFactoryClosed(this); eventListeners.destroyListeners(); }
public JbpmSchemaUpdate(Configuration cfg, Settings settings) throws HibernateException { this.configuration = cfg; dialect = settings.getDialect(); connectionProvider = settings.getConnectionProvider(); exceptions = new ArrayList(); }
public ConnectionProvider getConnectionProvider() { return settings.getConnectionProvider(); }