FileDocCategorySizeDatePackage
SessionFactory.javaAPI DocHibernate 3.2.58344Mon Dec 05 16:37:00 GMT 2005org.hibernate

SessionFactory

public interface SessionFactory implements Serializable, Referenceable
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

Fields Summary
Constructors Summary
Methods Summary
public voidclose()
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 voidevict(java.lang.Class persistentClass)
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 voidevict(java.lang.Class persistentClass, java.io.Serializable id)
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 voidevictCollection(java.lang.String roleName)
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 voidevictCollection(java.lang.String roleName, java.io.Serializable id)
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 voidevictEntity(java.lang.String entityName)
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 voidevictEntity(java.lang.String entityName, java.io.Serializable id)
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 voidevictQueries()
Evict any query result sets cached in the default query cache region.

public voidevictQueries(java.lang.String cacheRegion)
Evict any query result sets cached in the named query cache region.

public java.util.MapgetAllClassMetadata()
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 java.util.MapgetAllCollectionMetadata()
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 org.hibernate.metadata.ClassMetadatagetClassMetadata(java.lang.Class persistentClass)
Get the ClassMetadata associated with the given entity class

see
org.hibernate.metadata.ClassMetadata

public org.hibernate.metadata.ClassMetadatagetClassMetadata(java.lang.String entityName)
Get the ClassMetadata associated with the given entity name

see
org.hibernate.metadata.ClassMetadata
since
3.0

public org.hibernate.metadata.CollectionMetadatagetCollectionMetadata(java.lang.String roleName)
Get the CollectionMetadata associated with the named collection role

see
org.hibernate.metadata.CollectionMetadata

public org.hibernate.classic.SessiongetCurrentSession()
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 java.util.SetgetDefinedFilterNames()
Obtain a set of the names of all filters defined on this SessionFactory.

return
The set of filter names.

public org.hibernate.engine.FilterDefinitiongetFilterDefinition(java.lang.String filterName)
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 org.hibernate.stat.StatisticsgetStatistics()
Get the statistics for this session factory

public booleanisClosed()
Was this SessionFactory already closed?

public org.hibernate.classic.SessionopenSession(java.sql.Connection connection)
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.SessionopenSession(Interceptor interceptor)
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.SessionopenSession(java.sql.Connection connection, Interceptor interceptor)
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.SessionopenSession()
Create database connection and open a Session on it.

return
Session
throws
HibernateException

public StatelessSessionopenStatelessSession()
Get a new stateless session.

public StatelessSessionopenStatelessSession(java.sql.Connection connection)
Get a new stateless session for the given JDBC connection.