org.springframework.batch.item.database.JpaPagingItemReader Java Examples

The following examples show how to use org.springframework.batch.item.database.JpaPagingItemReader. 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: UserReader.java    From spring-cloud with Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "")
@Qualifier("jpaPagingItemReader")
public ItemReader<User> jpaPagingItemReader() {
    JpaPagingItemReader<User> reader = new JpaPagingItemReader<User>();
    String sqlQuery = "select * from user where id like :limit ";
    JpaNativeQueryProvider<User> queryProvider = new JpaNativeQueryProvider<User>();
    queryProvider.setSqlQuery(sqlQuery);
    queryProvider.setEntityClass(User.class);
    reader.setEntityManagerFactory(emf);
    reader.setPageSize(3);
    reader.setQueryProvider(queryProvider);
    reader.setParameterValues(Collections.<String, Object>singletonMap("limit", "%"));
    reader.setSaveState(true);
    return reader;
}
 
Example #2
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<Employee> taxCalculatorItemReader(@Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();

    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.GET_UNPROCESSED_EMPLOYEES_BY_YEAR_AND_MONTH_QUERY);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("year", stepExecution.getJobParameters().getLong("year").intValue());
    parameters.put("month", stepExecution.getJobParameters().getLong("month").intValue());
    parameters.put("jobExecutionId", stepExecution.getJobExecutionId());
    employeeItemReader.setParameterValues(parameters);
    employeeItemReader.setSaveState(false);
    return employeeItemReader;
}
 
Example #3
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<Employee> taxCalculatorItemReaderSlave(@Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.GET_UNPROCESSED_EMPLOYEES_BY_YEAR_AND_MONTH_QUERY_SLAVE);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("year", stepExecution.getJobParameters().getLong("year").intValue());
    parameters.put("month", stepExecution.getJobParameters().getLong("month").intValue());
    parameters.put("jobExecutionId", stepExecution.getJobExecutionId());
    parameters.put("minId", stepExecution.getExecutionContext().getLong("minValue"));
    parameters.put("maxId", stepExecution.getExecutionContext().getLong("maxValue"));
    employeeItemReader.setParameterValues(parameters);
    return employeeItemReader;
}
 
Example #4
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<TaxCalculation> wsCallItemReader(@Value("#{jobParameters[year]}") Long year, @Value("#{jobParameters[month]}") Long month, @Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<TaxCalculation> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.FIND_BY_YEAR_AND_MONTH_QUERY);
    Map<String, Object> queryParams = new HashMap<>();
    queryParams.put("year", year.intValue());
    queryParams.put("month", month.intValue());
    queryParams.put("jobExecutionId", stepExecution.getJobExecutionId());
    employeeItemReader.setParameterValues(queryParams);
    employeeItemReader.setSaveState(false);
    return employeeItemReader;
}
 
Example #5
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
public JpaPagingItemReader<Employee> generatePDFItemReader() {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(Employee.GET_ALL_QUERY);
    return employeeItemReader;
}
 
Example #6
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<Employee> taxCalculatorItemReader(@Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.GET_UNPROCESSED_EMPLOYEES_BY_YEAR_AND_MONTH_QUERY_SLAVE);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("year", stepExecution.getJobParameters().getLong("year").intValue());
    parameters.put("month", stepExecution.getJobParameters().getLong("month").intValue());
    parameters.put("jobExecutionId", stepExecution.getJobExecutionId());
    parameters.put("minId", stepExecution.getExecutionContext().getLong("minValue"));
    parameters.put("maxId", stepExecution.getExecutionContext().getLong("maxValue"));
    employeeItemReader.setParameterValues(parameters);
    return employeeItemReader;
}
 
Example #7
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<TaxCalculation> wsCallItemReader(@Value("#{jobParameters[year]}") Long year, @Value("#{jobParameters[month]}") Long month, @Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<TaxCalculation> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.FIND_BY_YEAR_AND_MONTH_QUERY);
    Map<String, Object> queryParams = new HashMap<>();
    queryParams.put("year", year.intValue());
    queryParams.put("month", month.intValue());
    queryParams.put("jobExecutionId", stepExecution.getJobExecutionId());
    employeeItemReader.setParameterValues(queryParams);
    employeeItemReader.setSaveState(false);
    return employeeItemReader;
}
 
Example #8
Source File: ItemReaderWriterConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
public JpaPagingItemReader<Employee> generatePDFItemReader() {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(Employee.GET_ALL_QUERY);
    return employeeItemReader;
}