Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » orm » hibernate3 » annotation » [javadoc | source]
org.springframework.orm.hibernate3.annotation
public class: AnnotationSessionFactoryBean [javadoc | source]
java.lang.Object
   org.springframework.orm.hibernate3.AbstractSessionFactoryBean
      org.springframework.orm.hibernate3.LocalSessionFactoryBean
         org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

All Implemented Interfaces:
    ResourceLoaderAware, BeanClassLoaderAware, PersistenceExceptionTranslator, DisposableBean, InitializingBean, FactoryBean

Subclass of Spring's standard LocalSessionFactoryBean for Hibernate, supporting JDK 1.5+ annotation metadata for mappings.

Note: This class requires Hibernate 3.2 or higher, with the Java Persistence API and the Hibernate Annotations add-on present.

Example for an AnnotationSessionFactoryBean bean definition:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>test.package.Foo</value>
<value>test.package.Bar</value>
</list>
</property>
</bean>
Or when using classpath scanning for autodetection of entity classes:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="test.package"/>
</bean>
Fields inherited from org.springframework.orm.hibernate3.AbstractSessionFactoryBean:
logger
Constructor:
 public AnnotationSessionFactoryBean() 
Method from org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean Summary:
postProcessAnnotationConfiguration,   postProcessConfiguration,   postProcessMappings,   scanPackages,   setAnnotatedClasses,   setAnnotatedPackages,   setConfigurationClass,   setEntityTypeFilters,   setPackagesToScan,   setResourceLoader
Methods from org.springframework.orm.hibernate3.LocalSessionFactoryBean:
afterSessionFactoryCreation,   buildSessionFactory,   createDatabaseSchema,   destroy,   dropDatabaseSchema,   executeSchemaScript,   executeSchemaStatement,   getConfigTimeCacheProvider,   getConfigTimeDataSource,   getConfigTimeLobHandler,   getConfigTimeTransactionManager,   getConfiguration,   getHibernateProperties,   newConfiguration,   newSessionFactory,   postProcessConfiguration,   postProcessMappings,   setBeanClassLoader,   setCacheProvider,   setCacheableMappingLocations,   setCollectionCacheStrategies,   setConfigLocation,   setConfigLocations,   setConfigurationClass,   setEntityCacheStrategies,   setEntityInterceptor,   setEventListeners,   setFilterDefinitions,   setHibernateProperties,   setJtaTransactionManager,   setLobHandler,   setMappingDirectoryLocations,   setMappingJarLocations,   setMappingLocations,   setMappingResources,   setNamingStrategy,   setSchemaUpdate,   setTypeDefinitions,   updateDatabaseSchema
Methods from org.springframework.orm.hibernate3.AbstractSessionFactoryBean:
afterPropertiesSet,   afterSessionFactoryCreation,   beforeSessionFactoryDestruction,   buildSessionFactory,   convertHibernateAccessException,   destroy,   getDataSource,   getObject,   getObjectType,   getSessionFactory,   isExposeTransactionAwareSessionFactory,   isSingleton,   isUseTransactionAwareDataSource,   setDataSource,   setExposeTransactionAwareSessionFactory,   setJdbcExceptionTranslator,   setUseTransactionAwareDataSource,   translateExceptionIfPossible,   wrapSessionFactoryIfNecessary
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean Detail:
 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.
 protected final  void postProcessConfiguration(Configuration config) throws HibernateException 
 protected  void postProcessMappings(Configuration config) throws HibernateException 
    Reads metadata from annotated classes and packages into the AnnotationConfiguration instance.
 protected  void scanPackages(AnnotationConfiguration config) 
    Perform Spring-based scanning for entity classes.
 public  void setAnnotatedClasses(Class[] annotatedClasses) 
    Specify annotated classes, for which mappings will be read from class-level JDK 1.5+ annotation metadata.
 public  void setAnnotatedPackages(String[] annotatedPackages) 
    Specify the names of annotated packages, for which package-level JDK 1.5+ annotation metadata will be read.
 public  void setConfigurationClass(Class configurationClass) 
 public  void setEntityTypeFilters(TypeFilter[] entityTypeFilters) 
    Specify custom type filters for Spring-based scanning for entity classes.

    Default is to search all specified packages for classes annotated with @javax.persistence.Entity, @javax.persistence.Embeddable or @javax.persistence.MappedSuperclass.

 public  void setPackagesToScan(String[] packagesToScan) 
    Set whether to use Spring-based scanning for entity classes in the classpath instead of listing annotated classes explicitly.

    Default is none. Specify packages to search for autodetection of your entity classes in the classpath. This is analogous to Spring's component-scan feature (org.springframework.context.annotation.ClassPathBeanDefinitionScanner ).

 public  void setResourceLoader(ResourceLoader resourceLoader)