use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project tutorials by eugenp.
the class PersistenceConfig method sessionFactory.
@Bean
public LocalSessionFactoryBean sessionFactory() {
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(restDataSource());
sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project classify-system by anverliedoit.
the class JPAConfig method sessionFactory.
@Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setHibernateProperties(hibernateProperties());
sessionFactory.setPackagesToScan("com.remswork.project.alice.model");
return sessionFactory;
}
use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project PublicCMS-preview by sanluan.
the class ApplicationConfig method hibernateSessionFactory.
/**
* Hibernate 会话工厂类
*
* @param dataSource
* @return hibernate session factory
* @throws PropertyVetoException
* @throws IOException
*/
@Bean
public FactoryBean<SessionFactory> hibernateSessionFactory(DataSource dataSource) throws PropertyVetoException, IOException {
LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setPackagesToScan("com.publiccms.entities");
Properties properties = PropertiesLoaderUtils.loadAllProperties(env.getProperty("cms.hibernate.configFilePath"));
properties.setProperty("hibernate.search.default.indexBase", getDirPath("/indexes/"));
MultiTokenizerFactory.setName(env.getProperty("cms.tokenizerFactory"));
bean.setHibernateProperties(properties);
return bean;
}
use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project dhis2-core by dhis2.
the class HibernateConfig method sessionFactory.
@Bean
@DependsOn("flyway")
public LocalSessionFactoryBean sessionFactory(DataSource dataSource, @Qualifier("hibernateConfigurationProvider") HibernateConfigurationProvider hibernateConfigurationProvider) {
Objects.requireNonNull(dataSource);
Objects.requireNonNull(hibernateConfigurationProvider);
Properties hibernateProperties = hibernateConfigurationProvider.getConfiguration().getProperties();
Objects.requireNonNull(hibernateProperties);
List<Resource> jarResources = hibernateConfigurationProvider.getJarResources();
List<Resource> directoryResources = hibernateConfigurationProvider.getDirectoryResources();
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMappingJarLocations(jarResources.toArray(new Resource[0]));
sessionFactory.setMappingDirectoryLocations(directoryResources.toArray(new Resource[0]));
sessionFactory.setAnnotatedClasses(DeletedObject.class);
sessionFactory.setHibernateProperties(hibernateProperties);
return sessionFactory;
}
use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project midpoint by Evolveum.
the class SqlRepositoryBeanConfig method sessionFactory.
@Bean
@ConditionalOnMissingBean
public LocalSessionFactoryBean sessionFactory(DataSource dataSource, SqlRepositoryConfiguration configuration, MidPointImplicitNamingStrategy midPointImplicitNamingStrategy, MidPointPhysicalNamingStrategy midPointPhysicalNamingStrategy, EntityStateInterceptor entityStateInterceptor) {
LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
// While dataSource == dataSourceFactory.getDataSource(), we're using dataSource as
// parameter to assure, that Spring already called the factory method. Explicit is good.
bean.setDataSource(dataSource);
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.dialect", configuration.getHibernateDialect());
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", configuration.getHibernateHbm2ddl());
hibernateProperties.setProperty("hibernate.id.new_generator_mappings", "true");
hibernateProperties.setProperty("hibernate.jdbc.batch_size", "20");
hibernateProperties.setProperty("javax.persistence.validation.mode", "none");
hibernateProperties.setProperty("hibernate.transaction.coordinator_class", "jdbc");
hibernateProperties.setProperty("hibernate.hql.bulk_id_strategy", "org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy");
bean.setHibernateProperties(hibernateProperties);
bean.setImplicitNamingStrategy(midPointImplicitNamingStrategy);
bean.setPhysicalNamingStrategy(midPointPhysicalNamingStrategy);
bean.setAnnotatedPackages("com.evolveum.midpoint.repo.sql.type");
bean.setPackagesToScan("com.evolveum.midpoint.repo.sql.data.common", "com.evolveum.midpoint.repo.sql.data.common.any", "com.evolveum.midpoint.repo.sql.data.common.container", "com.evolveum.midpoint.repo.sql.data.common.embedded", "com.evolveum.midpoint.repo.sql.data.common.enums", "com.evolveum.midpoint.repo.sql.data.common.id", "com.evolveum.midpoint.repo.sql.data.common.other", "com.evolveum.midpoint.repo.sql.data.common.type", "com.evolveum.midpoint.repo.sql.data.audit");
bean.setEntityInterceptor(entityStateInterceptor);
return bean;
}
Aggregations