AnnotationSessionFactoryBean annotationSessionFactoryBean = new AnnotationSessionFactoryBean(); annotationSessionFactoryBean.setPackagesToScan(new String[]{"com.sample"});
@Bean public SessionFactory sessionFactory() throws Exception { AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean(); bean.setDataSource(dataSource()); bean.setPackagesToScan(new String[] {"org.springframework.issues"}); bean.setHibernateProperties(hibernateProps()); bean.afterPropertiesSet(); return bean.getObject(); }
AnnotationSessionFactoryBean sfb = new AnnotationSessionFactoryBean(); sfb.setDataSource( ds ); sfb.setHibernateProperties( hibProps); sfb.setPackagesToScan( ... ); sfb.initialise(); SessionFactory sf = sfb.getObject();
@Bean public SessionFactory sessionFactory() throws Exception { AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean(); bean.setDataSource(dataSource()); bean.setPackagesToScan(new String[] {"org.springframework.issues"}); bean.setHibernateProperties(hibernateProps()); bean.afterPropertiesSet(); return bean.getObject(); }
@Configuration //@ComponentScan(basePackages = "de.webapp.daocustomer", excludeFilters = {@ComponentScan.Filter(Configuration.class), @ComponentScan.Filter(Controller.class)}) @ImportResource({"classpath*:componentScan.xml","classpath*:properties-config.xml","classpath*:security-context.xml"}) public class AppConfig { ... @Bean public SessionFactory sessionFactory() throws Exception { AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean(); bean.setDataSource(dataSource()); bean.setPackagesToScan(new String[] {"de.webapp"}); bean.setHibernateProperties(hibernateProps()); bean.afterPropertiesSet(); return bean.getObject(); }
sessionFactory.setDataSource(dataSource()); String[] pckage={"com.argus.intenew"}; sessionFactory.setPackagesToScan(pckage); sessionFactory.setHibernateProperties(hibProperties()); return sessionFactory;