Invalid record 'batches', in group 'file', in stream 'bank': Repeating segments without any child field component must have minOccurs=maxOccurs

826 views
Skip to first unread message

Renato Souza

unread,
Sep 8, 2014, 11:34:27 AM9/8/14
to bea...@googlegroups.com
Hi. First congrats for the great lib.
I'm having some kind of grouping issue. There are some similar errors around, but i've read all of them, with no success on my problem.
My xml mapping file is something like this:

<stream name="bank" format="fixedlength" >
    <parser>
        <property name="recordTerminator" value="\r\n" />
    </parser>
    <group name="file" order="1" class="com.bank.BankFile">
        <record name="header" order="1" minOccurs="1" maxOccurs="1" class="bank.BankHeader" />
        <record name="batches" order="2" minOccurs="1" maxOccurs="unbounded" collection="list" class="bank.BankTransaction"/>
        <record name="trailer" order="3" minOccurs="1" maxOccurs="1" class="bank.BankTrailer"/>
    </group>
</stream>


And my class structure looks like this:

public class BankFile {

    private BankHeader header;
    private List<BankTransaction> batches = new ArrayList<BankTransaction>();
    private BankTrailer trailer;

}


Each one of this classes (except for BankFile) are annotated with its proper fixed length annotations.
But when I try to run, it gives me the following error:

org.beanio.BeanIOConfigurationException: Invalid record 'batches', in group 'file', in stream 'bank': Repeating segments without any child field component must have minOccurs=maxOccurs
    at org.beanio.internal.compiler.ProcessorSupport.process(ProcessorSupport.java:93)


I think there is something wrong on the way i'm using this bankTransactions.. something on the record using collections.
Because I have other mapping files very similar and working pretty well. This is the only difference.

Any help? Thx!

Kevin

unread,
Sep 9, 2014, 10:31:49 PM9/9/14
to bea...@googlegroups.com
Did you define any fields for the "batches" record / BankTransaction class?

Thanks,
Kevin

Renato Souza

unread,
Sep 10, 2014, 8:29:51 AM9/10/14
to bea...@googlegroups.com
Yes, but its defined by annotation like shown below:


public class BankTransaction {

    @Field(at = 0, length = 1, align = Align.RIGHT, required = true)
    private int identification = 1;

    @Field(at = 1, length = 1, required = true)
    private Integer inscriptionType;

    @Field(at = 2, length = 15, padding = '0', align = Align.RIGHT, required = true, keepPadding = true)
    private String document;

    @Field(at = 17, length = 30, align = Align.RIGHT, required = true)
    private String name;

Kevin

unread,
Sep 10, 2014, 10:47:27 PM9/10/14
to bea...@googlegroups.com
I think you just need to annotate that class with @Record.

You'll probably also need to set rid=true on one of those fields for identifying the record.

Thanks,
Kevin
Reply all
Reply to author
Forward
0 new messages