All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.SessionFactory Maven / Gradle / Ivy

The newest version!
//$Id: SessionFactory.java 8754 2005-12-05 23:36:59Z steveebersole $
package org.hibernate;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Map;
import java.util.Set;

import javax.naming.Referenceable;

import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.stat.Statistics;
import org.hibernate.engine.FilterDefinition;

/**
 * Creates Sessions. Usually an application has a single SessionFactory.
 * Threads servicing client requests obtain Sessions from the factory.
*
* Implementors must be threadsafe.
*
* SessionFactorys are immutable. The behaviour of a SessionFactory is * controlled by properties supplied at configuration time. These properties are defined * on Environment. * * @see Session * @see org.hibernate.cfg.Environment * @see org.hibernate.cfg.Configuration * @see org.hibernate.connection.ConnectionProvider * @see org.hibernate.transaction.TransactionFactory * @author Gavin King */ public interface SessionFactory extends Referenceable, Serializable { /** * Open a Session on the given connection. *

* Note that the second-level cache will be disabled if you * supply a JDBC connection. Hibernate will not be able to track * any statements you might have executed in the same transaction. * Consider implementing your own ConnectionProvider. * * @param connection a connection provided by the application. * @return Session */ public org.hibernate.classic.Session openSession(Connection connection); /** * Create database connection and open a Session on it, specifying an * interceptor. * * @param interceptor a session-scoped interceptor * @return Session * @throws HibernateException */ public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException; /** * Open a Session on the given connection, specifying an interceptor. *

* Note that the second-level cache will be disabled if you * supply a JDBC connection. Hibernate will not be able to track * any statements you might have executed in the same transaction. * Consider implementing your own ConnectionProvider. * * @param connection a connection provided by the application. * @param interceptor a session-scoped interceptor * @return Session */ public org.hibernate.classic.Session openSession(Connection connection, Interceptor interceptor); /** * Create database connection and open a Session on it. * * @return Session * @throws HibernateException */ public org.hibernate.classic.Session openSession() throws HibernateException; /** * Obtains the current session. The definition of what exactly "current" * means controlled by the {@link org.hibernate.context.CurrentSessionContext} impl configured * for use. *

* Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext} * is not configured but a JTA {@link org.hibernate.transaction.TransactionManagerLookup} * is configured this will default to the {@link org.hibernate.context.JTASessionContext} * impl. * * @return The current session. * @throws HibernateException Indicates an issue locating a suitable current session. */ public org.hibernate.classic.Session getCurrentSession() throws HibernateException; /** * Get the ClassMetadata associated with the given entity class * * @see org.hibernate.metadata.ClassMetadata */ public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException; /** * Get the ClassMetadata associated with the given entity name * * @see org.hibernate.metadata.ClassMetadata * @since 3.0 */ public ClassMetadata getClassMetadata(String entityName) throws HibernateException; /** * Get the CollectionMetadata associated with the named collection role * * @see org.hibernate.metadata.CollectionMetadata */ public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException; /** * Get all ClassMetadata as a Map from entityname String * to metadata object * * @see org.hibernate.metadata.ClassMetadata * @return a map from String an entity name to ClassMetaData * @since 3.0 changed key from Class to String */ public Map getAllClassMetadata() throws HibernateException; /** * Get all CollectionMetadata as a Map from role name * to metadata object * * @see org.hibernate.metadata.CollectionMetadata * @return a map from String to CollectionMetadata */ public Map getAllCollectionMetadata() throws HibernateException; /** * Get the statistics for this session factory */ public Statistics getStatistics(); /** * Destroy this SessionFactory and release all resources (caches, * connection pools, etc). It is the responsibility of the application * to ensure that there are no open Sessions before calling * close(). */ public void close() throws HibernateException; /** * Was this SessionFactory already closed? */ public boolean isClosed(); /** * Evict all entries from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evict(Class persistentClass) throws HibernateException; /** * Evict an entry from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evict(Class persistentClass, Serializable id) throws HibernateException; /** * Evict all entries from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evictEntity(String entityName) throws HibernateException; /** * Evict an entry from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evictEntity(String entityName, Serializable id) throws HibernateException; /** * Evict all entries from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evictCollection(String roleName) throws HibernateException; /** * Evict an entry from the second-level cache. This method occurs outside * of any transaction; it performs an immediate "hard" remove, so does not respect * any transaction isolation semantics of the usage strategy. Use with care. */ public void evictCollection(String roleName, Serializable id) throws HibernateException; /** * Evict any query result sets cached in the default query cache region. */ public void evictQueries() throws HibernateException; /** * Evict any query result sets cached in the named query cache region. */ public void evictQueries(String cacheRegion) throws HibernateException; /** * Get a new stateless session. */ public StatelessSession openStatelessSession(); /** * Get a new stateless session for the given JDBC connection. */ public StatelessSession openStatelessSession(Connection connection); /** * Obtain a set of the names of all filters defined on this SessionFactory. * * @return The set of filter names. */ public Set getDefinedFilterNames(); /** * Obtain the definition of a filter by name. * * @param filterName The name of the filter for which to obtain the definition. * @return The filter definition. * @throws HibernateException If no filter defined with the given name. */ public FilterDefinition getFilterDefinition(String filterName) throws HibernateException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy