Spring Framework

org.springframework.orm.hibernate4
Class LocalSessionFactoryBuilder

java.lang.Object
  extended by org.hibernate.cfg.Configuration
      extended by org.springframework.orm.hibernate4.LocalSessionFactoryBuilder
All Implemented Interfaces:
java.io.Serializable

public class LocalSessionFactoryBuilder
extends org.hibernate.cfg.Configuration

A Spring-provided extension of the standard Hibernate Configuration class, adding SpringSessionContext as a default and providing convenient ways to specify a DataSource and an application class loader.

This is designed for programmatic use, e.g. in @Bean factory methods. Consider using LocalSessionFactoryBean for XML bean definition files.

Since:
3.1
Author:
Juergen Hoeller
See Also:
LocalSessionFactoryBean, Serialized Form

Field Summary
 
Fields inherited from class org.hibernate.cfg.Configuration
auxiliaryDatabaseObjects, classes, collections, columnNameBindingPerTable, extendsQueue, filterDefinitions, imports, namedQueries, namedSqlQueries, namingStrategy, propertyReferences, secondPasses, settingsFactory, sqlFunctions, sqlResultSetMappings, tableNameBinding, tables, typeDefs, xmlHelper
 
Constructor Summary
LocalSessionFactoryBuilder(javax.sql.DataSource dataSource)
          Create a new LocalSessionFactoryBuilder for the given DataSource.
LocalSessionFactoryBuilder(javax.sql.DataSource dataSource, java.lang.ClassLoader classLoader)
          Create a new LocalSessionFactoryBuilder for the given DataSource.
LocalSessionFactoryBuilder(javax.sql.DataSource dataSource, ResourceLoader resourceLoader)
          Create a new LocalSessionFactoryBuilder for the given DataSource.
 
Method Summary
 LocalSessionFactoryBuilder addAnnotatedClasses(java.lang.Class<?>... annotatedClasses)
          Add the given annotated classes in a batch.
 LocalSessionFactoryBuilder addPackages(java.lang.String... annotatedPackages)
          Add the given annotated packages in a batch.
 org.hibernate.SessionFactory buildSessionFactory()
          Build the SessionFactory.
 LocalSessionFactoryBuilder scanPackages(java.lang.String... packagesToScan)
          Perform Spring-based scanning for entity classes, registering them as annotated classes with this Configuration.
 
Methods inherited from class org.hibernate.cfg.Configuration
add, addAuxiliaryDatabaseObject, addCacheableFile, addCacheableFile, addClass, addDirectory, addDocument, addFile, addFile, addFilterDefinition, addInputStream, addJar, addProperties, addResource, addResource, addSqlFunction, addURL, addXML, buildMapping, buildMappings, buildSettings, buildSettings, configure, configure, configure, configure, configure, createMappings, doConfigure, doConfigure, findPossibleExtends, generateDropSchemaScript, generateSchemaCreationScript, generateSchemaUpdateScript, getClassMapping, getClassMappings, getCollectionMapping, getCollectionMappings, getConfigurationInputStream, getEntityNotFoundDelegate, getEntityResolver, getEventListeners, getFilterDefinitions, getImports, getInterceptor, getNamedQueries, getNamedSQLQueries, getNamingStrategy, getProperties, getProperty, getSessionFactoryObserver, getSqlFunctions, getSqlResultSetMappings, getTableMappings, mergeProperties, parseMappingElement, reset, secondPassCompile, secondPassCompileForeignKeys, setCacheConcurrencyStrategy, setCacheConcurrencyStrategy, setCollectionCacheConcurrencyStrategy, setCollectionCacheConcurrencyStrategy, setEntityNotFoundDelegate, setEntityResolver, setInterceptor, setListener, setListener, setListeners, setListeners, setNamingStrategy, setProperties, setProperty, setSessionFactoryObserver, validateSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalSessionFactoryBuilder

public LocalSessionFactoryBuilder(javax.sql.DataSource dataSource)
Create a new LocalSessionFactoryBuilder for the given DataSource.

Parameters:
dataSource - the JDBC DataSource that the resulting Hibernate SessionFactory should be using (may be null)

LocalSessionFactoryBuilder

public LocalSessionFactoryBuilder(javax.sql.DataSource dataSource,
                                  java.lang.ClassLoader classLoader)
Create a new LocalSessionFactoryBuilder for the given DataSource.

Parameters:
dataSource - the JDBC DataSource that the resulting Hibernate SessionFactory should be using (may be null)
classLoader - the ClassLoader to load application classes from

LocalSessionFactoryBuilder

public LocalSessionFactoryBuilder(javax.sql.DataSource dataSource,
                                  ResourceLoader resourceLoader)
Create a new LocalSessionFactoryBuilder for the given DataSource.

Parameters:
dataSource - the JDBC DataSource that the resulting Hibernate SessionFactory should be using (may be null)
classLoader - the ResourceLoader to load application classes from
Method Detail

addAnnotatedClasses

public LocalSessionFactoryBuilder addAnnotatedClasses(java.lang.Class<?>... annotatedClasses)
Add the given annotated classes in a batch.

See Also:
#addAnnotatedClass, scanPackages(java.lang.String...)

addPackages

public LocalSessionFactoryBuilder addPackages(java.lang.String... annotatedPackages)
Add the given annotated packages in a batch.

See Also:
#addPackage, scanPackages(java.lang.String...)

scanPackages

public LocalSessionFactoryBuilder scanPackages(java.lang.String... packagesToScan)
                                        throws org.hibernate.HibernateException
Perform Spring-based scanning for entity classes, registering them as annotated classes with this Configuration.

Parameters:
packagesToScan - one or more Java package names
Throws:
org.hibernate.HibernateException - if scanning fails for any reason

buildSessionFactory

public org.hibernate.SessionFactory buildSessionFactory()
                                                 throws org.hibernate.HibernateException
Build the SessionFactory.

Overrides:
buildSessionFactory in class org.hibernate.cfg.Configuration
Throws:
org.hibernate.HibernateException

Spring Framework