我正在尝试读取具有数百万条记录的数据库表,因此我正在使用 JdbcPagingItemReader。
但是,我现在处于测试阶段,我正在尝试限制我可以使用JdbcPagingItemReader. 我知道这应该很简单,它只是隐藏在某个地方。
这就是我的读者的样子:
@Bean (name = "metadataItemReader")
public ItemReader<DocumentMetadata> itemReader( @Value( "${count}" ) int count ) {
JdbcPagingItemReader<DocumentMetadata> reader = new JdbcPagingItemReader<>();
final SqlPagingQueryProviderFactoryBean sqlPagingQueryProviderFactoryBean = new SqlPagingQueryProviderFactoryBean();
sqlPagingQueryProviderFactoryBean.setDataSource(dataSource);
sqlPagingQueryProviderFactoryBean.setSelectClause("select id, file_path, file_name, extension, created_by, TO_CHAR(create_date, 'yyyy-mm-dd hh24:mi:ss') as create_date");
sqlPagingQueryProviderFactoryBean.setFromClause("from document_metadata");
//sqlPagingQueryProviderFactoryBean.l
sqlPagingQueryProviderFactoryBean.setSortKey("id");
try {
reader.setQueryProvider(sqlPagingQueryProviderFactoryBean.getObject());
} catch (Exception e) {
log.error(e.getMessage());
}
reader.setDataSource(dataSource);
reader.setPageSize(10);
reader.setRowMapper( new MetadataRowMapper() );
return reader;
}
动漫人物
相关分类