在春季批处理中记录拆分和分组 [英] Record splitting and grouping in spring batch

查看:112
本文介绍了在春季批处理中记录拆分和分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要分割我的输入文件,该文件包含不同长度的记录并键入一些bean.我能够使用CompositeItemReader将每个记录映射到不同的bean.但是这些记录之间存在一些父子关系.我想形成一个包含子bean的bean.感谢您的帮助.

I have a requirement to split my input file which contains records of different length and type some beans. I am able to map each record to different bean using CompositeItemReader. But there is some parent-child relation exists between these records. I want to form a bean which contains child beans. Any help is appreciated.

这是我的示例输入文件.

This is my sample input file.

AB,01,05,HHGFG,05 CD,452,63,FDD,07,54,76,EQWED PT,GGG,76,YYY CD,08、06,ASW,97、55、66,BT AB,96,87,KKK,03 PT,TIPWQ,19,YEQ PT,ROPRG,39,PRVM

AB,01,05,HHGFG,05 CD,452,63,FDD,07,54,76,EQWED PT,GGG,76,YYY CD,08,06,ASW,97,55,66,BT AB,96,87,KKK,03 PT,TIPWQ,19,YEQ PT,ROPRG,39,PRVM

此处AB被视为父记录.我的细分以AB *,CD *,PT *

Here AB is considered as parent record. My segments start with AB*, CD*, PT*

推荐答案

顶级域对象的创建是ItemReader的责任,因此此类聚合应在阅读阶段完成.
SB-sample-projects 中,有一个 另一个示例位于 Spring Batch:聚合的读者/作家问题

Top level domain object creation is responsability of ItemReader so this type of aggregation should be done in reading phase.
In SB-sample-projects there is a multilineOrder sample where you have a skeleton about how to resolve this type of problem; of course you have to resolve "manually" parent/child relationship between objects and manage errors during read.
Another example at Spring Batch :Aggregated reader / writer Issue

这篇关于在春季批处理中记录拆分和分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆