org.jboss.seam.persistence
Class HibernateSessionFactory

java.lang.Object
  extended by org.jboss.seam.persistence.HibernateSessionFactory

@Scope(value=APPLICATION)
@BypassInterceptors
@Startup
public class HibernateSessionFactory
extends Object

A Seam component that bootstraps a Hibernate SessionFactory

Loads Hibernate configuration options by checking:

  • hibernate.properties in root of the classpath
  • hibernate.cfg.xml in root of the classpath
  • cfgResourceName as location of a cfg.xml file
  • factory-supplied cfgProperties options

    Note that this factory only supports cfg.xml files or programmatic cfgProperties supplied to the factory. Any hibernate.properties are always loaded from the classpath.

    Mapping metadata can be supplied via

  • mappingClasses: equivalent to <mapping class="..."/>
  • mappingFiles: equivalent to <mapping file="..."/>
  • mappingJars: equivalent to <mapping jar="..."/>
  • mappingPackages: equivalent to <mapping package="..."/>
  • mappingResources: equivalent to <mapping resource="..."/>

    or via cfg.xml files.

    The jndiProperties are convenience, the factory will automatically prefix regular JNDI properties for use as Hibernate configuration properties.

    Author:
    Gavin King, Christian Bauer

    Constructor Summary
    HibernateSessionFactory()
               
     
    Method Summary
    protected  org.hibernate.SessionFactory createSessionFactory()
               
     Map<String,String> getCfgProperties()
               
     String getCfgResourceName()
               
     List<String> getMappingClasses()
               
     List<String> getMappingFiles()
               
     List<String> getMappingJars()
               
     List<String> getMappingPackages()
               
     List<String> getMappingResources()
               
     org.hibernate.cfg.NamingStrategy getNamingStrategy()
               
     org.hibernate.SessionFactory getSessionFactory()
               
     void setCfgProperties(Map<String,String> cfgProperties)
               
     void setCfgResourceName(String cfgFileName)
               
     void setMappingClasses(List<String> mappingClasses)
               
     void setMappingFiles(List<String> mappingFiles)
               
     void setMappingJars(List<String> mappingJars)
               
     void setMappingPackages(List<String> mappingPackages)
               
     void setMappingResources(List<String> mappingResources)
               
     void setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)
               
     void shutdown()
               
     void startup()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    HibernateSessionFactory

    public HibernateSessionFactory()
    Method Detail

    getSessionFactory

    @Unwrap
    public org.hibernate.SessionFactory getSessionFactory()
                                                   throws Exception
    Throws:
    Exception

    startup

    @Create
    public void startup()
                 throws Exception
    Throws:
    Exception

    shutdown

    @Destroy
    public void shutdown()

    createSessionFactory

    protected org.hibernate.SessionFactory createSessionFactory()
                                                         throws ClassNotFoundException
    Throws:
    ClassNotFoundException

    getCfgResourceName

    public String getCfgResourceName()

    setCfgResourceName

    public void setCfgResourceName(String cfgFileName)

    getNamingStrategy

    public org.hibernate.cfg.NamingStrategy getNamingStrategy()

    setNamingStrategy

    public void setNamingStrategy(org.hibernate.cfg.NamingStrategy namingStrategy)

    getCfgProperties

    public Map<String,String> getCfgProperties()

    setCfgProperties

    public void setCfgProperties(Map<String,String> cfgProperties)

    getMappingClasses

    public List<String> getMappingClasses()

    setMappingClasses

    public void setMappingClasses(List<String> mappingClasses)

    getMappingFiles

    public List<String> getMappingFiles()

    setMappingFiles

    public void setMappingFiles(List<String> mappingFiles)

    getMappingJars

    public List<String> getMappingJars()

    setMappingJars

    public void setMappingJars(List<String> mappingJars)

    getMappingPackages

    public List<String> getMappingPackages()

    setMappingPackages

    public void setMappingPackages(List<String> mappingPackages)

    getMappingResources

    public List<String> getMappingResources()

    setMappingResources

    public void setMappingResources(List<String> mappingResources)