Java Code Examples for org.springframework.orm.hibernate4.LocalSessionFactoryBean#setPackagesToScan()

The following examples show how to use org.springframework.orm.hibernate4.LocalSessionFactoryBean#setPackagesToScan() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryTestConfig.java    From Project with Apache License 2.0 6 votes vote down vote up
@Bean
public SessionFactory sessionFactoryBean() {
  try {
    LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean();
    lsfb.setDataSource(dataSource());
    lsfb.setPackagesToScan("spittr.domain");
    Properties props = new Properties();
    props.setProperty("dialect", "org.hibernate.dialect.H2Dialect");
    lsfb.setHibernateProperties(props);
    lsfb.afterPropertiesSet();
    SessionFactory object = lsfb.getObject();
    return object;
  } catch (IOException e) {
    return null;
  }
}
 
Example 2
Source File: RecoverableSessionFactoryBean.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void afterPropertiesSet() throws IOException {
    long startTime = System.currentTimeMillis();

    // init SessionFactoryWrapper
    sessionFactoryWrapper = new SessionFactoryWrapper();

    try {
        // init LocalSessionFactoryBean
        localSessionFactoryBean = new LocalSessionFactoryBean();
        localSessionFactoryBean.setDataSource(dataSource);
        localSessionFactoryBean.setHibernateProperties(hibernateProperties);
        localSessionFactoryBean.setPackagesToScan(packagesToScan);

        localSessionFactoryBean.afterPropertiesSet();

        SessionFactory sessionFactory = localSessionFactoryBean.getObject();
        sessionFactoryWrapper.setSessionFactory(sessionFactory);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }

    long endTime = System.currentTimeMillis();
    logger.info("hibernate init cost {} ms", (endTime - startTime));
}
 
Example 3
Source File: DbTestContext.java    From OpERP with MIT License 6 votes vote down vote up
/**
 * 
 * This setups the session factory
 */
@Bean
public LocalSessionFactoryBean sessionFactory(Environment environment,
		DataSource dataSource) {

	/**
	 * 
	 * Getting packageOfModelBean from package of message bean
	 * 
	 */

	LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();

	factoryBean.setDataSource(dataSource);
	factoryBean
			.setHibernateProperties(buildHibernateProperties(environment));
	factoryBean.setPackagesToScan(packagesToScan);
	return factoryBean;
}
 
Example 4
Source File: HibernateTransactionManagerConfiguration.java    From hypersistence-optimizer with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalSessionFactoryBean originalSessionFactory() {
    LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
    localSessionFactoryBean.setDataSource(dataSource());
    localSessionFactoryBean.setPackagesToScan(packagesToScan());
    localSessionFactoryBean.setHibernateProperties(additionalProperties());
    return localSessionFactoryBean;
}
 
Example 5
Source File: GreetingServiceConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalSessionFactoryBean getSessionFactory(DataSource dataSource,
		@Qualifier("hibernateProperties") Properties hibernateProperties) {
	LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean();
	lsfb.setDataSource(dataSource);
	lsfb.setPackagesToScan("com.link_intersystems.examples.domain");
	return lsfb;
}
 
Example 6
Source File: GreetingServiceConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalSessionFactoryBean getSessionFactory(DataSource dataSource,
		@Qualifier("hibernateProperties") Properties hibernateProperties) {
	LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean();
	lsfb.setDataSource(dataSource);
	lsfb.setPackagesToScan("com.link_intersystems.examples.domain");
	return lsfb;
}