org.springframework.orm.hibernate3.annotation
Class AnnotationSessionFactoryBean

java.lang.Object
  extended by org.springframework.orm.hibernate3.LocalSessionFactoryBean
      extended by org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
All Implemented Interfaces:
DisposableBean, FactoryBean, InitializingBean

public class AnnotationSessionFactoryBean
extends LocalSessionFactoryBean

Subclass of Spring's standard LocalSessionFactoryBean for Hibernate3, supporting JDK 1.5+ annotation metadata for mappings. Requires the Hibernate3 Annotation add-on to be present.

Example bean definition:

 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
   <property name="dataSource">
     <ref bean="dataSource"/>
   </property>
   <property name="annotatedClasses">
     <list>
       <value>test.package.Foo</value>
       <value>test.package.Bar</value>
     </list>
   </property>
   <property name="annotatedPackages">
     <list>
       <value>test.package</value>
     </list>
   </property>
 </bean>

Since:
1.2.2
Author:
Juergen Hoeller
See Also:
LocalSessionFactoryBean.setDataSource(javax.sql.DataSource), LocalSessionFactoryBean.setHibernateProperties(java.util.Properties), setAnnotatedClasses(java.lang.Class[]), setAnnotatedPackages(java.lang.String[])

Field Summary
 
Fields inherited from class org.springframework.orm.hibernate3.LocalSessionFactoryBean
logger
 
Constructor Summary
AnnotationSessionFactoryBean()
           
 
Method Summary
protected  void postProcessAnnotationConfiguration(AnnotationConfiguration config)
          To be implemented by subclasses that want to to perform custom post-processing of the AnnotationConfiguration object after this FactoryBean performed its default initialization.
protected  void postProcessConfiguration(Configuration config)
          Reads metadata from annotated classes and packages into the AnnotationConfiguration instance.
 void setAnnotatedClasses(Class[] annotatedClasses)
          Specify annotated classes, for which mappings will be read from class-level JDK 1.5+ annotation metadata.
 void setAnnotatedPackages(String[] annotatedPackages)
          Specify the names of annotated packages, for which package-level JDK 1.5+ annotation metadata will be read.
 void setConfigurationClass(Class configurationClass)
          Specify the Hibernate Configuration class to use.
 
Methods inherited from class org.springframework.orm.hibernate3.LocalSessionFactoryBean
afterPropertiesSet, createDatabaseSchema, destroy, dropDatabaseSchema, executeSchemaScript, executeSchemaStatement, getConfigTimeDataSource, getConfigTimeLobHandler, getConfigTimeTransactionManager, getConfiguration, getHibernateProperties, getObject, getObjectType, getTransactionAwareSessionFactoryProxy, isSingleton, newConfiguration, newSessionFactory, setCacheableMappingLocations, setCollectionCacheStrategies, setConfigLocation, setConfigLocations, setDataSource, setEntityCacheStrategies, setEntityInterceptor, setEventListeners, setExposeTransactionAwareSessionFactory, setFilterDefinitions, setHibernateProperties, setJtaTransactionManager, setLobHandler, setMappingDirectoryLocations, setMappingJarLocations, setMappingLocations, setMappingResources, setNamingStrategy, setSchemaUpdate, setTypeDefinitions, setUseTransactionAwareDataSource, updateDatabaseSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationSessionFactoryBean

public AnnotationSessionFactoryBean()
Method Detail

setConfigurationClass

public void setConfigurationClass(Class configurationClass)
Description copied from class: LocalSessionFactoryBean
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.

Overrides:
setConfigurationClass in class LocalSessionFactoryBean
See Also:
LocalSessionFactoryBean.setConfigLocation(org.springframework.core.io.Resource), Configuration, AnnotationConfiguration

setAnnotatedClasses

public void setAnnotatedClasses(Class[] annotatedClasses)
Specify annotated classes, for which mappings will be read from class-level JDK 1.5+ annotation metadata.

See Also:
AnnotationConfiguration.addAnnotatedClass(Class)

setAnnotatedPackages

public void setAnnotatedPackages(String[] annotatedPackages)
Specify the names of annotated packages, for which package-level JDK 1.5+ annotation metadata will be read.

See Also:
AnnotationConfiguration.addPackage(String)

postProcessConfiguration

protected final void postProcessConfiguration(Configuration config)
                                       throws HibernateException
Reads metadata from annotated classes and packages into the AnnotationConfiguration instance.

Calls postProcessAnnotationConfiguration afterwards, to give subclasses the chance to perform custom post-processing.

Overrides:
postProcessConfiguration in class LocalSessionFactoryBean
Parameters:
config - the current Configuration object
Throws:
HibernateException - in case of Hibernate initialization errors
See Also:
postProcessAnnotationConfiguration(org.hibernate.cfg.AnnotationConfiguration)

postProcessAnnotationConfiguration

protected void postProcessAnnotationConfiguration(AnnotationConfiguration config)
                                           throws HibernateException
To be implemented by subclasses that want to to perform custom post-processing of the AnnotationConfiguration object after this FactoryBean performed its default initialization.

Parameters:
config - the current AnnotationConfiguration object
Throws:
HibernateException - in case of Hibernate initialization errors


Copyright (c) 2002-2007 The Spring Framework Project.