ch.elca.el4j.services.persistence.hibernate.entityfinder
Class EntityDetectorAnnotationSessionFactoryBean

java.lang.Object
  extended by org.springframework.orm.hibernate3.AbstractSessionFactoryBean
      extended by org.springframework.orm.hibernate3.LocalSessionFactoryBean
          extended by org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
              extended by ch.elca.el4j.services.persistence.hibernate.entityfinder.EntityDetectorAnnotationSessionFactoryBean
All Implemented Interfaces:
BeanClassLoaderAware, DisposableBean, FactoryBean<SessionFactory>, InitializingBean, ResourceLoaderAware, PersistenceExceptionTranslator

public class EntityDetectorAnnotationSessionFactoryBean
extends AnnotationSessionFactoryBean
implements InitializingBean

Extends AnnotationSessionFactoryBean.
Detects all classes that have a \@Entity annotation under a given parent package (indicated with the property autoDetectEntityPackage). Source of the idea: secutix project

File-location:
EntityDetectorAnnotationSessionFactoryBean
Last check-in date:
2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) by swismer for revision 3874

Field Summary
 
Fields inherited from class org.springframework.orm.hibernate3.AbstractSessionFactoryBean
logger
 
Constructor Summary
EntityDetectorAnnotationSessionFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
          really do the searching.
 Class<?>[] getAnnotatedClasses()
          Just to have them available for tests
protected  String[] getAutoDetectEntityPackage()
           
 boolean isJpaFullSupportEnabled()
           
protected  SessionFactory newSessionFactory(Configuration config)
          
 void setAnnotatedClasses(Class[] annotatedClasses)
          Explicitly specify annotated entity classes.
 void setAutoDetectAnnotatedPackages(String[] annotatedPackages)
          Specify the names of annotated packages, for which (including all sub packages) package-level JDK 1.5+ annotation metadata will be read.
 void setAutoDetectEntityPackage(String... pack)
          Sets the 1 or n packages in which the entities are defined Sample package: "org.hibernate.tests.entities"
 void setJpaFullSupportEnabled(boolean enabled)
          Set the enabled flag for the full JPA support.
 
Methods inherited from class org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
postProcessAnnotationConfiguration, postProcessConfiguration, postProcessMappings, scanPackages, setAnnotatedPackages, setConfigurationClass, setEntityTypeFilters, setPackagesToScan, setResourceLoader
 
Methods inherited from class org.springframework.orm.hibernate3.LocalSessionFactoryBean
afterSessionFactoryCreation, buildSessionFactory, createDatabaseSchema, destroy, dropDatabaseSchema, executeSchemaScript, executeSchemaStatement, getConfigTimeCacheProvider, getConfigTimeDataSource, getConfigTimeLobHandler, getConfigTimeTransactionManager, getConfiguration, getHibernateProperties, newConfiguration, setBeanClassLoader, setCacheableMappingLocations, setCacheProvider, setCacheRegionFactory, setCollectionCacheStrategies, setConfigLocation, setConfigLocations, setEntityCacheStrategies, setEntityInterceptor, setEventListeners, setFilterDefinitions, setHibernateProperties, setJtaTransactionManager, setLobHandler, setMappingDirectoryLocations, setMappingJarLocations, setMappingLocations, setMappingResources, setNamingStrategy, setSchemaUpdate, setTypeDefinitions, updateDatabaseSchema, validateDatabaseSchema
 
Methods inherited from class org.springframework.orm.hibernate3.AbstractSessionFactoryBean
beforeSessionFactoryDestruction, convertHibernateAccessException, getDataSource, getObject, getObjectType, getSessionFactory, isExposeTransactionAwareSessionFactory, isSingleton, isUseTransactionAwareDataSource, setDataSource, setExposeTransactionAwareSessionFactory, setJdbcExceptionTranslator, setUseTransactionAwareDataSource, translateExceptionIfPossible, wrapSessionFactoryIfNecessary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityDetectorAnnotationSessionFactoryBean

public EntityDetectorAnnotationSessionFactoryBean()
Method Detail

setAutoDetectEntityPackage

public void setAutoDetectEntityPackage(String... pack)
Sets the 1 or n packages in which the entities are defined Sample package: "org.hibernate.tests.entities"

Parameters:
pack - The parent package name that contains the target entities (as strings)

getAutoDetectEntityPackage

protected String[] getAutoDetectEntityPackage()
Returns:
Returns the package prefixes in which we do the auto detection of entities.

setAutoDetectAnnotatedPackages

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

Parameters:
annotatedPackages - a list of annotated packages

setAnnotatedClasses

public void setAnnotatedClasses(Class[] annotatedClasses)
Explicitly specify annotated entity classes.

Overrides:
setAnnotatedClasses in class AnnotationSessionFactoryBean

getAnnotatedClasses

public Class<?>[] getAnnotatedClasses()
Just to have them available for tests

Returns:

setJpaFullSupportEnabled

public void setJpaFullSupportEnabled(boolean enabled)
Set the enabled flag for the full JPA support.

Parameters:
enabled -

isJpaFullSupportEnabled

public boolean isJpaFullSupportEnabled()
Returns:
if the full Java Persistence API support is enabled.

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
really do the searching.

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class AbstractSessionFactoryBean
Throws:
Exception

newSessionFactory

protected SessionFactory newSessionFactory(Configuration config)
                                    throws HibernateException

Overrides:
newSessionFactory in class LocalSessionFactoryBean
Throws:
HibernateException


Copyright © 2005-2011 ELCA. All Rights Reserved.