将春季批次的可选字段设置为linemapper
private LineMapper<CSVFileRequest> lineMapper() {
DefaultLineMapper<CSVFileRequest> lineMapper = new DefaultLineMapper<>();
DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
lineTokenizer.setDelimiter(",");
lineTokenizer.setStrict(false);
lineTokenizer.setNames("caller_id","order_id","shipment","amount","acc_num","due_date");
BeanWrapperFieldSetMapper<CSVFileRequest> fieldSetMapper = new BeanWrapperFieldSetMapper<>();
fieldSetMapper.setTargetType(CSVFileRequest.class);
lineMapper.setLineTokenizer(lineTokenizer);
lineMapper.setFieldSetMapper(fieldSetMapper);
return lineMapper;
}
我如何设置自定义字段,例如在给定的CSV文件中,我没有其他列,在CSV文件中只有列,此处数据应插入两个不同的表中,一个属于Caller_id,并且其他属于所有其他字段,现在的问题是我如何知道,其他字段是否在CSV文件中给出。
private LineMapper<CSVFileRequest> lineMapper() {
DefaultLineMapper<CSVFileRequest> lineMapper = new DefaultLineMapper<>();
DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
lineTokenizer.setDelimiter(",");
lineTokenizer.setStrict(false);
lineTokenizer.setNames("caller_id","order_id","shipment","amount","acc_num","due_date");
BeanWrapperFieldSetMapper<CSVFileRequest> fieldSetMapper = new BeanWrapperFieldSetMapper<>();
fieldSetMapper.setTargetType(CSVFileRequest.class);
lineMapper.setLineTokenizer(lineTokenizer);
lineMapper.setFieldSetMapper(fieldSetMapper);
return lineMapper;
}
How Can I set the custom fields, like In given CSV file, I don't have the other columns, in csv file there is only column, and here the data is to be inserted in two different tables, one belongs to caller_id, and other belongs to all other fields, now the question is how would I know, the other fields are given in csv file or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过setincluded设置它
you can set it by setIncluded