Example usage for org.springframework.batch.core.repository.support JobRepositoryFactoryBean setIsolationLevelForCreate

List of usage examples for org.springframework.batch.core.repository.support JobRepositoryFactoryBean setIsolationLevelForCreate

Introduction

In this page you can find the example usage for org.springframework.batch.core.repository.support JobRepositoryFactoryBean setIsolationLevelForCreate.

Prototype

public void setIsolationLevelForCreate(String isolationLevelForCreate) 

Source Link

Document

public setter for the isolation level to be used for the transaction when job execution entities are initially created.

Usage

From source file:io.getlime.push.configuration.BatchSendingConfiguration.java

private JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(dataSource);//  www . j a va 2  s. c  o m
    factory.setTransactionManager(transactionManager);
    factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
    factory.afterPropertiesSet();
    return factory.getObject();
}

From source file:com.example.configuration.BatchConfiguration.java

public JobRepository getJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(config.dataSource());
    factory.setTransactionManager(transactionManager);
    factory.setLobHandler(lobHandler());
    factory.setDatabaseType(DatabaseType.fromMetaData(config.dataSource()).name());
    factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
    factory.afterPropertiesSet();//from w  w w  .j  ava2s.  c  o m
    return (JobRepository) factory.getObject();
}

From source file:uk.ac.kcl.batch.BatchConfigurer.java

@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();//w  w  w .  ja  va 2 s .c  o m
    return factory.getObject();
}

From source file:de.codecentric.batch.configuration.TaskExecutorBatchConfigurer.java

protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(dataSource);//  w  w w  . j  a v  a  2s  . c o  m
    factory.setTransactionManager(transactionManager);
    String isolationLevelForCreate = env.getProperty("batch.repository.isolationlevelforcreate");
    if (isolationLevelForCreate != null) {
        factory.setIsolationLevelForCreate(isolationLevelForCreate);
    }
    String tablePrefix = env.getProperty("batch.repository.tableprefix");
    if (tablePrefix != null) {
        factory.setTablePrefix(tablePrefix);
    }
    factory.afterPropertiesSet();
    return factory.getObject();
}

From source file:org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.java

protected JobRepository createJobRepository() throws Exception {
    JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
    factory.setDataSource(this.dataSource);
    if (this.entityManagerFactory != null) {
        logger.warn(// www  . jav a 2s . c  om
                "JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
        factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
    }
    String tablePrefix = this.properties.getTablePrefix();
    if (StringUtils.hasText(tablePrefix)) {
        factory.setTablePrefix(tablePrefix);
    }
    factory.setTransactionManager(getTransactionManager());
    factory.afterPropertiesSet();
    return factory.getObject();
}