Class SessionFactoryBean

  • All Implemented Interfaces:
    Disposable, Initializing, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>

    public class SessionFactoryBean
    extends Object
    implements org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>, Initializing, Disposable, org.springframework.beans.factory.BeanClassLoaderAware
    Version:
    $Id: SessionFactoryBean.java Feb 27, 2012 10:52:27 PM chaostone $
    Author:
    chaostone
    • Field Detail

      • logger

        protected org.slf4j.Logger logger
    • Constructor Detail

      • SessionFactoryBean

        public SessionFactoryBean()
    • Method Detail

      • setConfigLocations

        public void setConfigLocations​(org.springframework.core.io.Resource[] configLocations)
        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:
        Configuration.configure(java.net.URL)
      • setPersistLocations

        public void setPersistLocations​(org.springframework.core.io.Resource[] persistLocations)
      • setHibernateProperties

        public void setHibernateProperties​(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. It is also advisable to omit connection provider settings and use a Spring-set DataSource instead.

        See Also:
        setDataSource(javax.sql.DataSource)
      • getHibernateProperties

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

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

        protected void processProperties()
      • newConfiguration

        protected org.hibernate.cfg.Configuration newConfiguration()
                                                            throws org.hibernate.HibernateException
        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.

        Returns:
        the Configuration instance
        Throws:
        org.hibernate.HibernateException - in case of Hibernate initialization errors
        See Also:
        Configuration()
      • destroy

        public void destroy()
                     throws org.hibernate.HibernateException
        Specified by:
        destroy in interface Disposable
        Throws:
        org.hibernate.HibernateException
      • setBeanClassLoader

        public void setBeanClassLoader​(ClassLoader classLoader)
        Specified by:
        setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
      • getObject

        public org.hibernate.SessionFactory getObject()
        Specified by:
        getObject in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
      • getObjectType

        public Class<? extends org.hibernate.SessionFactory> getObjectType()
        Specified by:
        getObjectType in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
      • isSingleton

        public boolean isSingleton()
        Specified by:
        isSingleton in interface org.springframework.beans.factory.FactoryBean<org.hibernate.SessionFactory>
      • getDataSource

        public DataSource getDataSource()
      • setDataSource

        public void setDataSource​(DataSource dataSource)
      • getSessionFactory

        public org.hibernate.SessionFactory getSessionFactory()
      • setConfigurationClass

        public void setConfigurationClass​(Class<? extends org.hibernate.cfg.Configuration> configurationClass)
      • getConfiguration

        public org.hibernate.cfg.Configuration getConfiguration()
      • setStaticHbm

        public void setStaticHbm​(org.springframework.core.io.Resource staticHbm)