List of usage examples for org.springframework.batch.item.database JpaPagingItemReader JpaPagingItemReader
public JpaPagingItemReader()
From source file:ru.xxlabaza.test.batch.job.MyJobBeanConfiguration.java
@Bean(destroyMethod = "") // http://stackoverflow.com/a/23089536 @StepScope/*w w w .j a v a2 s. com*/ public JpaPagingItemReader<Person> reader(@Value("#{stepExecutionContext[from]}") Integer from, @Value("#{stepExecutionContext[to]}") Integer to) { val reader = new JpaPagingItemReader<Person>(); reader.setEntityManagerFactory(entityManagerFactory); reader.setSaveState(false); reader.setQueryString( "SELECT person " + "FROM Person AS person " + "WHERE person.id BETWEEN :from AND :to"); reader.setParameterValues(new HashMap<String, Object>() { { put("from", from); put("to", to); } }); return reader; }
From source file:org.springframework.batch.item.database.JpaPagingItemReaderAsyncTests.java
private JpaPagingItemReader<Foo> getItemReader() throws Exception { String jpqlQuery = "select f from Foo f"; JpaPagingItemReader<Foo> reader = new JpaPagingItemReader<Foo>(); reader.setQueryString(jpqlQuery);// w ww .j a v a 2s .co m reader.setEntityManagerFactory(entityManagerFactory); reader.setPageSize(PAGE_SIZE); reader.afterPropertiesSet(); reader.setSaveState(false); reader.open(new ExecutionContext()); return reader; }