Java Doc for LocalSessionFactoryBean.java in  » J2EE » spring-framework-2.0.6 » org » springframework » orm » hibernate3 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.orm.hibernate3 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.hibernate3.AbstractSessionFactoryBean
      org.springframework.orm.hibernate3.LocalSessionFactoryBean

All known Subclasses:   org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean,
LocalSessionFactoryBean
public class LocalSessionFactoryBean extends AbstractSessionFactoryBean (Code)
org.springframework.beans.factory.FactoryBean that creates a Hibernate org.hibernate.SessionFactory . This is the usual way to set up a shared Hibernate SessionFactory in a Spring application context; the SessionFactory can then be passed to Hibernate-based DAOs via dependency injection.

Configuration settings can either be read from a Hibernate XML file, specified as "configLocation", or completely via this class. A typical local configuration consists of one or more "mappingResources", various "hibernateProperties" (not strictly necessary), and a "dataSource" that the SessionFactory should use. The latter can also be specified via Hibernate properties, but "dataSource" supports any Spring-configured DataSource, instead of relying on Hibernate's own connection providers.

This SessionFactory handling strategy is appropriate for most types of applications, from Hibernate-only single database apps to ones that need distributed transactions. Either HibernateTransactionManager or org.springframework.transaction.jta.JtaTransactionManager can be used for transaction demarcation, with the latter only necessary for transactions which span multiple databases.

This factory bean will by default expose a transaction-aware SessionFactory proxy, letting data access code work with the plain Hibernate SessionFactory and its getCurrentSession() method, while still being able to participate in current Spring-managed transactions: with any transaction management strategy, either local or JTA / EJB CMT, and any transaction synchronization mechanism, either Spring or JTA. Furthermore, getCurrentSession() will also seamlessly work with a request-scoped Session managed by org.springframework.orm.hibernate3.support.OpenSessionInViewFilter / org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor .

Requires Hibernate 3.0.3 or later. Note that this factory will use "on_close" as default Hibernate connection release mode, unless in the case of a "jtaTransactionManager" specified, for the reason that this is appropriate for most Spring-based applications (in particular when using Spring's HibernateTransactionManager). Hibernate 3.0 used "on_close" as its own default too; however, Hibernate 3.1 changed this to "auto" (i.e. "after_statement" or "after_transaction").
author:
   Juergen Hoeller
since:
   1.2
See Also:   HibernateTemplate.setSessionFactory
See Also:   HibernateTransactionManager.setSessionFactory
See Also:   LocalSessionFactoryBean.setExposeTransactionAwareSessionFactory
See Also:   LocalSessionFactoryBean.setJtaTransactionManager
See Also:   org.hibernate.SessionFactory.getCurrentSession
See Also:   HibernateTransactionManager





Method Summary
protected  voidafterSessionFactoryCreation()
     Executes schema update if requested.
protected  SessionFactorybuildSessionFactory()
    
public  voidcreateDatabaseSchema()
     Execute schema creation script, determined by the Configuration object used for creating the SessionFactory.
public  voiddestroy()
     Allows for schema export on shutdown.
public  voiddropDatabaseSchema()
     Execute schema drop script, determined by the Configuration object used for creating the SessionFactory.
protected  voidexecuteSchemaScript(Connection con, String[] sql)
     Execute the given schema script on the given JDBC Connection.

Note that the default implementation will log unsuccessful statements and continue to execute.

protected  voidexecuteSchemaStatement(Statement stmt, String sql)
     Execute the given schema SQL on the given JDBC Statement.

Note that the default implementation will log unsuccessful statements and continue to execute.

public static  DataSourcegetConfigTimeDataSource()
     Return the DataSource for the currently configured Hibernate SessionFactory, to be used by LocalDataSourceConnectionProvoder.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards.

public static  LobHandlergetConfigTimeLobHandler()
     Return the LobHandler for the currently configured Hibernate SessionFactory, to be used by UserType implementations like ClobStringType.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards.

public static  TransactionManagergetConfigTimeTransactionManager()
     Return the JTA TransactionManager for the currently configured Hibernate SessionFactory, to be used by LocalTransactionManagerLookup.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards.

final public  ConfigurationgetConfiguration()
     Return the Configuration object used to build the SessionFactory.
public  PropertiesgetHibernateProperties()
     Return the Hibernate properties, if any.
protected  ConfigurationnewConfiguration()
     Subclasses can override this method to perform custom initialization of the Configuration instance used for SessionFactory creation.
protected  SessionFactorynewSessionFactory(Configuration config)
     Subclasses can override this method to perform custom initialization of the SessionFactory instance, creating it via the given Configuration object that got prepared by this LocalSessionFactoryBean.
protected  voidpostProcessConfiguration(Configuration config)
     To be implemented by subclasses that want to to perform custom post-processing of the Configuration object after this FactoryBean performed its default initialization.
public  voidsetCacheableMappingLocations(Resource[] cacheableMappingLocations)
     Set locations of cacheable Hibernate mapping files, for example as web app resource "/WEB-INF/mapping/example.hbm.xml".
public  voidsetCollectionCacheStrategies(Properties collectionCacheStrategies)
     Specify the cache strategies for persistent collections (with specific roles).
public  voidsetConfigLocation(Resource configLocation)
     Set the location of a single Hibernate XML config file, for example as classpath resource "classpath:hibernate.cfg.xml".
public  voidsetConfigLocations(Resource[] configLocations)
     Set the locations of multiple Hibernate XML config files, for example as classpath resources "classpath:hibernate.cfg.xml,classpath:extension.cfg.xml".
public  voidsetConfigurationClass(Class configurationClass)
     Specify the Hibernate Configuration class to use.
public  voidsetDataSource(DataSource dataSource)
     Set the DataSource to be used by the SessionFactory. If set, this will override corresponding settings in Hibernate properties.

If this is set, the Hibernate settings should not define a connection provider to avoid meaningless double configuration.

If using HibernateTransactionManager as transaction strategy, consider proxying your target DataSource with a LazyConnectionDataSourceProxy. This defers fetching of an actual JDBC Connection until the first JDBC Statement gets executed, even within JDBC transactions (as performed by HibernateTransactionManager).

public  voidsetEntityCacheStrategies(Properties entityCacheStrategies)
     Specify the cache strategies for entities (persistent classes or named entities).
public  voidsetEntityInterceptor(Interceptor entityInterceptor)
     Set a Hibernate entity interceptor that allows to inspect and change property values before writing to and reading from the database. Will get applied to any new Session created by this factory.

Such an interceptor can either be set at the SessionFactory level, i.e.

public  voidsetEventListeners(Map eventListeners)
     Specify the Hibernate event listeners to register, with listener types as keys and listener objects as values.

Instead of a single listener object, you can also pass in a list or set of listeners objects as value.

public  voidsetFilterDefinitions(FilterDefinition[] filterDefinitions)
     Specify the Hibernate FilterDefinitions to register with the SessionFactory.
public  voidsetHibernateProperties(Properties hibernateProperties)
     Set Hibernate properties, such as "hibernate.dialect".

Can be used to override values in a Hibernate XML config file, or to specify all necessary properties locally.

Note: Do not specify a transaction provider here when using Spring-driven transactions.

public  voidsetJtaTransactionManager(TransactionManager jtaTransactionManager)
     Set the JTA TransactionManager to be used for Hibernate's TransactionManagerLookup.
public  voidsetLobHandler(LobHandler lobHandler)
     Set the LobHandler to be used by the SessionFactory.
public  voidsetMappingDirectoryLocations(Resource[] mappingDirectoryLocations)
     Set locations of directories that contain Hibernate mapping resources, like "WEB-INF/mappings".
public  voidsetMappingJarLocations(Resource[] mappingJarLocations)
     Set locations of jar files that contain Hibernate mapping resources, like "WEB-INF/lib/example.hbm.jar".
public  voidsetMappingLocations(Resource[] mappingLocations)
     Set locations of Hibernate mapping files, for example as classpath resource "classpath:example.hbm.xml".
public  voidsetMappingResources(String[] mappingResources)
     Set Hibernate mapping resources to be found in the class path, like "example.hbm.xml" or "mypackage/example.hbm.xml".
public  voidsetNamingStrategy(NamingStrategy namingStrategy)
     Set a Hibernate NamingStrategy for the SessionFactory, determining the physical column and table names given the info in the mapping document.
public  voidsetSchemaUpdate(boolean schemaUpdate)
     Set whether to execute a schema update after SessionFactory initialization.
public  voidsetTypeDefinitions(TypeDefinitionBean[] typeDefinitions)
     Specify the Hibernate type definitions to register with the SessionFactory, as Spring TypeDefinitionBean instances.
public  voidsetUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)
     Set whether to use a transaction-aware DataSource for the SessionFactory, i.e.
public  voidupdateDatabaseSchema()
     Execute schema update script, determined by the Configuration object used for creating the SessionFactory.



Method Detail
afterSessionFactoryCreation
protected void afterSessionFactoryCreation() throws Exception(Code)
Executes schema update if requested.
See Also:   LocalSessionFactoryBean.setSchemaUpdate
See Also:   LocalSessionFactoryBean.updateDatabaseSchema()



buildSessionFactory
protected SessionFactory buildSessionFactory() throws Exception(Code)



createDatabaseSchema
public void createDatabaseSchema() throws DataAccessException(Code)
Execute schema creation script, determined by the Configuration object used for creating the SessionFactory. A replacement for Hibernate's SchemaExport class, to be invoked on application setup.

Fetch the LocalSessionFactoryBean itself rather than the exposed SessionFactory to be able to invoke this method, e.g. via LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");.

Uses the SessionFactory that this bean generates for accessing a JDBC connection to perform the script.
throws:
  DataAccessException - in case of script execution errors
See Also:   org.hibernate.cfg.Configuration.generateSchemaCreationScript
See Also:   org.hibernate.tool.hbm2ddl.SchemaExport.create




destroy
public void destroy() throws HibernateException(Code)
Allows for schema export on shutdown.



dropDatabaseSchema
public void dropDatabaseSchema() throws DataAccessException(Code)
Execute schema drop script, determined by the Configuration object used for creating the SessionFactory. A replacement for Hibernate's SchemaExport class, to be invoked on application setup.

Fetch the LocalSessionFactoryBean itself rather than the exposed SessionFactory to be able to invoke this method, e.g. via LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");.

Uses the SessionFactory that this bean generates for accessing a JDBC connection to perform the script.
throws:
  org.springframework.dao.DataAccessException - in case of script execution errors
See Also:   org.hibernate.cfg.Configuration.generateDropSchemaScript
See Also:   org.hibernate.tool.hbm2ddl.SchemaExport.drop




executeSchemaScript
protected void executeSchemaScript(Connection con, String[] sql) throws SQLException(Code)
Execute the given schema script on the given JDBC Connection.

Note that the default implementation will log unsuccessful statements and continue to execute. Override the executeSchemaStatement method to treat failures differently.
Parameters:
  con - the JDBC Connection to execute the script on
Parameters:
  sql - the SQL statements to execute
throws:
  SQLException - if thrown by JDBC methods
See Also:   LocalSessionFactoryBean.executeSchemaStatement




executeSchemaStatement
protected void executeSchemaStatement(Statement stmt, String sql) throws SQLException(Code)
Execute the given schema SQL on the given JDBC Statement.

Note that the default implementation will log unsuccessful statements and continue to execute. Override this method to treat failures differently.
Parameters:
  stmt - the JDBC Statement to execute the SQL on
Parameters:
  sql - the SQL statement to execute
throws:
  SQLException - if thrown by JDBC methods (and considered fatal)




getConfigTimeDataSource
public static DataSource getConfigTimeDataSource()(Code)
Return the DataSource for the currently configured Hibernate SessionFactory, to be used by LocalDataSourceConnectionProvoder.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards. It is thus only available during configuration.
See Also:   LocalSessionFactoryBean.setDataSource
See Also:   LocalDataSourceConnectionProvider




getConfigTimeLobHandler
public static LobHandler getConfigTimeLobHandler()(Code)
Return the LobHandler for the currently configured Hibernate SessionFactory, to be used by UserType implementations like ClobStringType.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards. It is thus only available during configuration.
See Also:   LocalSessionFactoryBean.setLobHandler
See Also:   org.springframework.orm.hibernate3.support.ClobStringType
See Also:   org.springframework.orm.hibernate3.support.BlobByteArrayType
See Also:   org.springframework.orm.hibernate3.support.BlobSerializableType




getConfigTimeTransactionManager
public static TransactionManager getConfigTimeTransactionManager()(Code)
Return the JTA TransactionManager for the currently configured Hibernate SessionFactory, to be used by LocalTransactionManagerLookup.

This instance will be set before initialization of the corresponding SessionFactory, and reset immediately afterwards. It is thus only available during configuration.
See Also:   LocalSessionFactoryBean.setJtaTransactionManager
See Also:   LocalTransactionManagerLookup




getConfiguration
final public Configuration getConfiguration()(Code)
Return the Configuration object used to build the SessionFactory. Allows access to configuration metadata stored there (rarely needed).
throws:
  IllegalStateException - if the Configuration object has not been initialized yet



getHibernateProperties
public Properties getHibernateProperties()(Code)
Return the Hibernate properties, if any. Mainly available for configuration through property paths that specify individual keys.



newConfiguration
protected Configuration newConfiguration() throws HibernateException(Code)
Subclasses can override this method to perform custom initialization of the Configuration instance used for SessionFactory creation. The properties of this LocalSessionFactoryBean will be applied to the Configuration object that gets returned here.

The default implementation creates a new Configuration instance. A custom implementation could prepare the instance in a specific way, or use a custom Configuration subclass. the Configuration instance
throws:
  HibernateException - in case of Hibernate initialization errors
See Also:   org.hibernate.cfg.Configuration.Configuration




newSessionFactory
protected SessionFactory newSessionFactory(Configuration config) throws HibernateException(Code)
Subclasses can override this method to perform custom initialization of the SessionFactory instance, creating it via the given Configuration object that got prepared by this LocalSessionFactoryBean.

The default implementation invokes Configuration's buildSessionFactory. A custom implementation could prepare the instance in a specific way, or use a custom SessionFactoryImpl subclass.
Parameters:
  config - Configuration prepared by this LocalSessionFactoryBean the SessionFactory instance
throws:
  HibernateException - in case of Hibernate initialization errors
See Also:   org.hibernate.cfg.Configuration.buildSessionFactory




postProcessConfiguration
protected void postProcessConfiguration(Configuration config) throws HibernateException(Code)
To be implemented by subclasses that want to to perform custom post-processing of the Configuration object after this FactoryBean performed its default initialization.
Parameters:
  config - the current Configuration object
throws:
  HibernateException - in case of Hibernate initialization errors



setCacheableMappingLocations
public void setCacheableMappingLocations(Resource[] cacheableMappingLocations)(Code)
Set locations of cacheable Hibernate mapping files, for example as web app resource "/WEB-INF/mapping/example.hbm.xml". Supports any resource location via Spring's resource abstraction, as long as the resource can be resolved in the file system.

Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
See Also:   org.hibernate.cfg.Configuration.addCacheableFile(java.io.File)




setCollectionCacheStrategies
public void setCollectionCacheStrategies(Properties collectionCacheStrategies)(Code)
Specify the cache strategies for persistent collections (with specific roles). This configuration setting corresponds to the <collection-cache> entry in the "hibernate.cfg.xml" configuration format.

For example:

 <property name="collectionCacheStrategies">
 <props>
 <prop key="com.mycompany.Order.items">read-write</prop>
 <prop key="com.mycompany.Product.categories">read-only,myRegion</prop>
 </props>
 </property>
Note that appending a cache region name (with a comma separator) is only supported on Hibernate 3.1, where this functionality is publically available.
Parameters:
  collectionCacheStrategies - properties that define collection cache strategies,with collection roles as keys and cache concurrency strategies as values
See Also:   org.hibernate.cfg.Configuration.setCollectionCacheConcurrencyStrategy(StringString)



setConfigLocation
public void setConfigLocation(Resource configLocation)(Code)
Set the location of a single Hibernate XML config file, for example as classpath resource "classpath:hibernate.cfg.xml".

Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.
See Also:   org.hibernate.cfg.Configuration.configure(java.net.URL)




setConfigLocations
public void setConfigLocations(Resource[] configLocations)(Code)
Set the locations of multiple Hibernate XML config files, for example as classpath resources "classpath:hibernate.cfg.xml,classpath:extension.cfg.xml".

Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.
See Also:   org.hibernate.cfg.Configuration.configure(java.net.URL)




setConfigurationClass
public void setConfigurationClass(Class configurationClass)(Code)
Specify the Hibernate Configuration class to use. Default is "org.hibernate.cfg.Configuration"; any subclass of this default Hibernate Configuration class can be specified.

Can be set to "org.hibernate.cfg.AnnotationConfiguration" for using Hibernate3 annotation support (initially only available as alpha download separate from the main Hibernate3 distribution).

Annotated packages and annotated classes can be specified via the corresponding tags in "hibernate.cfg.xml" then, so this will usually be combined with a "configLocation" property that points at such a standard Hibernate configuration file.
See Also:   LocalSessionFactoryBean.setConfigLocation
See Also:   org.hibernate.cfg.Configuration
See Also:   org.hibernate.cfg.AnnotationConfiguration




setDataSource
public void setDataSource(DataSource dataSource)(Code)
Set the DataSource to be used by the SessionFactory. If set, this will override corresponding settings in Hibernate properties.

If this is set, the Hibernate settings should not define a connection provider to avoid meaningless double configuration.

If using HibernateTransactionManager as transaction strategy, consider proxying your target DataSource with a LazyConnectionDataSourceProxy. This defers fetching of an actual JDBC Connection until the first JDBC Statement gets executed, even within JDBC transactions (as performed by HibernateTransactionManager). Such lazy fetching is particularly beneficial for read-only operations, in particular if the chances of resolving the result in the second-level cache are high.

As JTA and transactional JNDI DataSources already provide lazy enlistment of JDBC Connections, LazyConnectionDataSourceProxy does not add value with JTA (i.e. Spring's JtaTransactionManager) as transaction strategy.
See Also:   LocalSessionFactoryBean.setUseTransactionAwareDataSource
See Also:   LocalDataSourceConnectionProvider
See Also:   HibernateTransactionManager
See Also:   org.springframework.transaction.jta.JtaTransactionManager
See Also:   org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy




setEntityCacheStrategies
public void setEntityCacheStrategies(Properties entityCacheStrategies)(Code)
Specify the cache strategies for entities (persistent classes or named entities). This configuration setting corresponds to the <class-cache> entry in the "hibernate.cfg.xml" configuration format.

For example:

 <property name="entityCacheStrategies">
 <props>
 <prop key="com.mycompany.Customer">read-write</prop>
 <prop key="com.mycompany.Product">read-only,myRegion</prop>
 </props>
 </property>
Note that appending a cache region name (with a comma separator) is only supported on Hibernate 3.1, where this functionality is publically available.
Parameters:
  entityCacheStrategies - properties that define entity cache strategies,with class names as keys and cache concurrency strategies as values
See Also:   org.hibernate.cfg.Configuration.setCacheConcurrencyStrategy(StringString)



setEntityInterceptor
public void setEntityInterceptor(Interceptor entityInterceptor)(Code)
Set a Hibernate entity interceptor that allows to inspect and change property values before writing to and reading from the database. Will get applied to any new Session created by this factory.

Such an interceptor can either be set at the SessionFactory level, i.e. on LocalSessionFactoryBean, or at the Session level, i.e. on HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager. It's preferable to set it on LocalSessionFactoryBean or HibernateTransactionManager to avoid repeated configuration and guarantee consistent behavior in transactions.
See Also:   HibernateTemplate.setEntityInterceptor
See Also:   HibernateInterceptor.setEntityInterceptor
See Also:   HibernateTransactionManager.setEntityInterceptor
See Also:   org.hibernate.cfg.Configuration.setInterceptor




setEventListeners
public void setEventListeners(Map eventListeners)(Code)
Specify the Hibernate event listeners to register, with listener types as keys and listener objects as values.

Instead of a single listener object, you can also pass in a list or set of listeners objects as value. However, this is only supported on Hibernate 3.1.

See the Hibernate documentation for further details on listener types and associated listener interfaces.
Parameters:
  eventListeners - Map with listener type Strings as keys andlistener objects as values
See Also:   org.hibernate.cfg.Configuration.setListener(StringObject)




setFilterDefinitions
public void setFilterDefinitions(FilterDefinition[] filterDefinitions)(Code)
Specify the Hibernate FilterDefinitions to register with the SessionFactory. This is an alternative to specifying <<filter-def> elements in Hibernate mapping files.

Typically, the passed-in FilterDefinition objects will have been defined as Spring FilterDefinitionFactoryBeans, probably as inner beans within the LocalSessionFactoryBean definition.
See Also:   FilterDefinitionFactoryBean
See Also:   org.hibernate.cfg.Configuration.addFilterDefinition




setHibernateProperties
public void setHibernateProperties(Properties hibernateProperties)(Code)
Set Hibernate properties, such as "hibernate.dialect".

Can be used to override values in a Hibernate XML config file, or to specify all necessary properties locally.

Note: Do not specify a transaction provider here when using Spring-driven transactions. It is also advisable to omit connection provider settings and use a Spring-set DataSource instead.
See Also:   LocalSessionFactoryBean.setDataSource




setJtaTransactionManager
public void setJtaTransactionManager(TransactionManager jtaTransactionManager)(Code)
Set the JTA TransactionManager to be used for Hibernate's TransactionManagerLookup. If set, this will override corresponding settings in Hibernate properties. Allows to use a Spring-managed JTA TransactionManager for Hibernate's cache synchronization.

Note: If this is set, the Hibernate settings should not define a transaction manager lookup to avoid meaningless double configuration.
See Also:   LocalTransactionManagerLookup




setLobHandler
public void setLobHandler(LobHandler lobHandler)(Code)
Set the LobHandler to be used by the SessionFactory. Will be exposed at config time for UserType implementations.
See Also:   LocalSessionFactoryBean.getConfigTimeLobHandler
See Also:   org.hibernate.usertype.UserType
See Also:   org.springframework.orm.hibernate3.support.ClobStringType
See Also:   org.springframework.orm.hibernate3.support.BlobByteArrayType
See Also:   org.springframework.orm.hibernate3.support.BlobSerializableType



setMappingDirectoryLocations
public void setMappingDirectoryLocations(Resource[] mappingDirectoryLocations)(Code)
Set locations of directories that contain Hibernate mapping resources, like "WEB-INF/mappings".

Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
See Also:   org.hibernate.cfg.Configuration.addDirectory(java.io.File)




setMappingJarLocations
public void setMappingJarLocations(Resource[] mappingJarLocations)(Code)
Set locations of jar files that contain Hibernate mapping resources, like "WEB-INF/lib/example.hbm.jar".

Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
See Also:   org.hibernate.cfg.Configuration.addJar(java.io.File)




setMappingLocations
public void setMappingLocations(Resource[] mappingLocations)(Code)
Set locations of Hibernate mapping files, for example as classpath resource "classpath:example.hbm.xml". Supports any resource location via Spring's resource abstraction, for example relative paths like "WEB-INF/mappings/example.hbm.xml" when running in an application context.

Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
See Also:   org.hibernate.cfg.Configuration.addInputStream




setMappingResources
public void setMappingResources(String[] mappingResources)(Code)
Set Hibernate mapping resources to be found in the class path, like "example.hbm.xml" or "mypackage/example.hbm.xml". Analogous to mapping entries in a Hibernate XML config file. Alternative to the more generic setMappingLocations method.

Can be used to add to mappings from a Hibernate XML config file, or to specify all mappings locally.
See Also:   LocalSessionFactoryBean.setMappingLocations
See Also:   org.hibernate.cfg.Configuration.addResource




setNamingStrategy
public void setNamingStrategy(NamingStrategy namingStrategy)(Code)
Set a Hibernate NamingStrategy for the SessionFactory, determining the physical column and table names given the info in the mapping document.
See Also:   org.hibernate.cfg.Configuration.setNamingStrategy



setSchemaUpdate
public void setSchemaUpdate(boolean schemaUpdate)(Code)
Set whether to execute a schema update after SessionFactory initialization.

For details on how to make schema update scripts work, see the Hibernate documentation, as this class leverages the same schema update script support in org.hibernate.cfg.Configuration as Hibernate's own SchemaUpdate tool.
See Also:   org.hibernate.cfg.Configuration.generateSchemaUpdateScript
See Also:   org.hibernate.tool.hbm2ddl.SchemaUpdate




setTypeDefinitions
public void setTypeDefinitions(TypeDefinitionBean[] typeDefinitions)(Code)
Specify the Hibernate type definitions to register with the SessionFactory, as Spring TypeDefinitionBean instances. This is an alternative to specifying <<typedef> elements in Hibernate mapping files.

Unfortunately, Hibernate itself does not define a complete object that represents a type definition, hence the need for Spring's TypeDefinitionBean.
See Also:   TypeDefinitionBean
See Also:   org.hibernate.cfg.Mappings.addTypeDef(StringStringjava.util.Properties)




setUseTransactionAwareDataSource
public void setUseTransactionAwareDataSource(boolean useTransactionAwareDataSource)(Code)
Set whether to use a transaction-aware DataSource for the SessionFactory, i.e. whether to automatically wrap the passed-in DataSource with Spring's TransactionAwareDataSourceProxy.

Default is "false": LocalSessionFactoryBean is usually used with Spring's HibernateTransactionManager or JtaTransactionManager, both of which work nicely on a plain JDBC DataSource. Hibernate Sessions and their JDBC Connections are fully managed by the Hibernate/JTA transaction infrastructure in such a scenario.

If you switch this flag to "true", Spring's Hibernate access will be able to participate in JDBC-based transactions managed outside of Hibernate (for example, by Spring's DataSourceTransactionManager). This can be convenient if you need a different local transaction strategy for another O/R mapping tool, for example, but still want Hibernate access to join into those transactions.

A further benefit of this option is that plain Sessions opened directly via the SessionFactory, outside of Spring's Hibernate support, will still participate in active Spring-managed transactions. However, consider using Hibernate's getCurrentSession() method instead (see javadoc of "exposeTransactionAwareSessionFactory" property).

As a further effect, using a transaction-aware DataSource will apply remaining transaction timeouts to all created JDBC Statements. This means that all operations performed by the SessionFactory will automatically participate in Spring-managed transaction timeouts, not just queries. This adds value even for HibernateTransactionManager, but only on Hibernate 3.0, as there is a direct transaction timeout facility in Hibernate 3.1.

WARNING: When using a transaction-aware JDBC DataSource in combination with OpenSessionInViewFilter/Interceptor, whether participating in JTA or external JDBC-based transactions, it is strongly recommended to set Hibernate's Connection release mode to "after_transaction" or "after_statement", which guarantees proper Connection handling in such a scenario. In contrast to that, HibernateTransactionManager generally requires release mode "on_close".

Note: If you want to use Hibernate's Connection release mode "after_statement" with a DataSource specified on this LocalSessionFactoryBean (for example, a JTA-aware DataSource fetched from JNDI), switch this setting to "true". Else, the ConnectionProvider used underneath will vote against aggressive release and thus silently switch to release mode "after_transaction".
See Also:   LocalSessionFactoryBean.setDataSource
See Also:   LocalSessionFactoryBean.setExposeTransactionAwareSessionFactory
See Also:   org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy
See Also:   org.springframework.jdbc.datasource.DataSourceTransactionManager
See Also:   org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
See Also:   org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor
See Also:   HibernateTransactionManager
See Also:   org.springframework.transaction.jta.JtaTransactionManager




updateDatabaseSchema
public void updateDatabaseSchema() throws DataAccessException(Code)
Execute schema update script, determined by the Configuration object used for creating the SessionFactory. A replacement for Hibernate's SchemaUpdate class, for automatically executing schema update scripts on application startup. Can also be invoked manually.

Fetch the LocalSessionFactoryBean itself rather than the exposed SessionFactory to be able to invoke this method, e.g. via LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");.

Uses the SessionFactory that this bean generates for accessing a JDBC connection to perform the script.
throws:
  DataAccessException - in case of script execution errors
See Also:   LocalSessionFactoryBean.setSchemaUpdate
See Also:   org.hibernate.cfg.Configuration.generateSchemaUpdateScript
See Also:   org.hibernate.tool.hbm2ddl.SchemaUpdate




Fields inherited from org.springframework.orm.hibernate3.AbstractSessionFactoryBean
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.orm.hibernate3.AbstractSessionFactoryBean
public void afterPropertiesSet() throws Exception(Code)(Java Doc)
protected void afterSessionFactoryCreation() throws Exception(Code)(Java Doc)
protected void beforeSessionFactoryDestruction()(Code)(Java Doc)
abstract protected SessionFactory buildSessionFactory() throws Exception(Code)(Java Doc)
protected DataAccessException convertHibernateAccessException(HibernateException ex)(Code)(Java Doc)
public void destroy() throws HibernateException(Code)(Java Doc)
public Object getObject()(Code)(Java Doc)
public Class getObjectType()(Code)(Java Doc)
final protected SessionFactory getSessionFactory()(Code)(Java Doc)
protected SessionFactory getTransactionAwareSessionFactoryProxy(SessionFactory target)(Code)(Java Doc)
protected boolean isExposeTransactionAwareSessionFactory()(Code)(Java Doc)
public boolean isSingleton()(Code)(Java Doc)
public void setExposeTransactionAwareSessionFactory(boolean exposeTransactionAwareSessionFactory)(Code)(Java Doc)
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)(Code)(Java Doc)
public DataAccessException translateExceptionIfPossible(RuntimeException ex)(Code)(Java Doc)
protected SessionFactory wrapSessionFactoryIfNecessary(SessionFactory rawSf)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.