'Spring Batch, JdbcPagingItemReader - alias doesn't map to the Mapper bean attribute
select item_num
,T1.sht_name as "\"T1.sht_name\" (...alias set in Spring Batch Java code)
,T2.lct_num
from ITEM T1 INNER JOIN LOCATION T2
on T1.sht_name = T2.sht_name
where T1.code = 1
orderby item_num, T1.sht_name, T2.lct_num
I have set the above query in the provider.setSelectClause, provider.setFromClause and provider.setWhereClause respectively. I am setting the sort keys as:
sortConfiguration.put("item_num", Order.ASCENDING);
sortConfiguration.put("T1.sht_name", Order.ASCENDING);
sortConfiguration.put("lct_num", Order.ASCENDING);
Mapper bean is :
public class ItemBean implements Serializable {
private static final long serialVersionUID = 1L;
private int itemNum;
private String shtName;
private Integer lctNum;
}
reader bean:
@Bean
public JdbcPagingItemReader<ItemBean > testBatchReader() {
JdbcPagingItemReader<ItemBean > reader = new JdbcPagingItemReader<>();
reader.setDataSource(db2Config.db2DataSource());
reader.setQueryProvider(queryProvider());
reader.setPageSize(chunkSize);
reader.setRowMapper(new BeanPropertyRowMapper<>(ItemBean.class));
return reader;
}
However, when I execute the Batch, null is obtained for shtName. That implies the fetched column is not getting mapped to the Mapper bean attribute shtName. Any help would be appreciated. (I am thinking to use RepositoryItemReader if this cannot be mapped but there too I am not sure how to map the sort keys for the dependent table (LOCATION) column (T2.sht_name)).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
