gpt4 book ai didi

java - Spring 批处理 : How to configure PagingQueryProvider without a SortKeys

转载 作者:太空宇宙 更新时间:2023-11-04 09:53:24 25 4
gpt4 key购买 nike

我正在尝试配置 JdbcPagingItemReader bean,但我不确切知道表中列的名称,因此我想知道是否有一种方法可以在没有排序键的情况下配置 PagingQueryProvider。

@Bean
public JdbcPagingItemReader<Map<String, Object>> pagingItemReader(DataSource dataSource){
JdbcPagingItemReader<Map<String, Object>> itemReader = new JdbcPagingItemReader<>();
itemReader.setDataSource(dataSource);
itemReader.setQueryProvider(queryProvider());
itemReader.setPageSize(1000);

itemReader.setRowMapper(BatchConfiguration::rowMapper);

return itemReader;
}


/* This configuration throws the exception
* 'java.lang.IllegalArgumentException: sortKey must be specified'
*/
private MySqlPagingQueryProvider queryProvider(){
MySqlPagingQueryProvider queryProvider = new MySqlPagingQueryProvider();
queryProvider.setSelectClause("SELECT *");
queryProvider.setFromClause("FROM "+ clientTableName);

return queryProvider;
}

最佳答案

I'd like to know if there is a way to configure a PagingQueryProvider without a sort key.

不,这是不可能的。 sortKey 是构建 SQL 语句所必需的。以下是 reference documentation 的摘录:

The SqlPagingQueryProviderFactoryBean requires that you specify a select clause and a from clause. You can also provide an optional where clause. These clauses and the required sortKey are used to build an SQL statement.

关于java - Spring 批处理 : How to configure PagingQueryProvider without a SortKeys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54442415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com