Java Code Examples for org.springframework.batch.core.repository.support.JobRepositoryFactoryBean#setIsolationLevelForCreate()

The following examples show how to use org.springframework.batch.core.repository.support.JobRepositoryFactoryBean#setIsolationLevelForCreate() . 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: TaskExecutorBatchConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 6 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
	JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
	factory.setDataSource(dataSource);
	factory.setTransactionManager(transactionManager);
	factory.setSerializer(serializer);
	String isolationLevelForCreate = batchConfig.getRepository().getIsolationLevelForCreate();
	if (isolationLevelForCreate != null) {
		factory.setIsolationLevelForCreate(isolationLevelForCreate);
	}
	String tablePrefix = batchConfig.getRepository().getTablePrefix();
	if (tablePrefix != null) {
		factory.setTablePrefix(tablePrefix);
	}
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
Example 2
Source File: SpringBatchConfiguration.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE");
    factory.setDataSource(dataSource);
    factory.setTransactionManager(transactionManager);
    factory.setValidateTransactionState(false);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 3
Source File: MyBatchConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * JobRepository,用来注册Job的容器
 * jobRepositor的定义需要dataSource和transactionManager,Spring Boot已为我们自动配置了
 * 这两个类,Spring可通过方法注入已有的Bean
 *
 * @param dataSource
 * @param transactionManager
 * @return
 * @throws Exception
 */
@Bean
public JobRepository jobRepository(DruidDataSource dataSource, PlatformTransactionManager transactionManager) throws Exception {
    JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
    jobRepositoryFactoryBean.setDataSource(dataSource);
    jobRepositoryFactoryBean.setTransactionManager(transactionManager);
    jobRepositoryFactoryBean.setDatabaseType(String.valueOf(DatabaseType.ORACLE));
    jobRepositoryFactoryBean.setMaxVarCharLength(5000);
    // 下面事务隔离级别的配置是针对Oracle的
    jobRepositoryFactoryBean.setIsolationLevelForCreate("ISOLATION_READ_COMMITTED");
    jobRepositoryFactoryBean.afterPropertiesSet();
    return jobRepositoryFactoryBean.getObject();
}
 
Example 4
Source File: BatchConfigurer.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Override
protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(jobRepositoryDataSource);
    factory.setTransactionManager(getTransactionManager());
    //to avoid deadlocks on the Job repo in SQL SERVER 2008
    factory.setIsolationLevelForCreate("ISOLATION_REPEATABLE_READ");
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 5
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
protected JobRepository createJobRepository() throws Exception {
	JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
	factory.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE");
	factory.setDataSource(dataSource);
	factory.setTransactionManager(transactionManager);
	factory.setValidateTransactionState(false);
	factory.afterPropertiesSet();
	return factory.getObject();
}