Spring Batch - Skip Record On Process

后端 未结 4 1096
再見小時候
再見小時候 2021-01-03 02:18

I wanted to skip some record on process.

what i have tried is, i have created custom exception and throw the exception when i want to skip the record and its calling

4条回答
  •  不知归路
    2021-01-03 02:53

    @Component
    @Scope(value = "step")
    public class XyzItemProcessor implements ItemProcessor {
    
    @Override
    public ABCInfo process(ABCInfo abcInfo) throws Exception {
    
        if (abcInfo.getRecordType().equals("H") || extVoterInfo.getRecordType().equals("T"))
            return null;////this is how we skip particular record to persist in database
        else {
            return abcInfo;
        }
    }
    }
    

    Return null will skip the particular record to be persisted in database

提交回复
热议问题