4

I'm trying to have some inheritance in using bindy csv Dataformat (Camel 2.13.1) I have an abstract class and two concrete classe, each one inherit the base class.

ex

@CsvRecord(separator=";",generateHeaderColumns=true,skipFirstLine=true)
public abstract class AbstractBaseFormat {
    @DataField(columnName="FIELD1",pos=1)
    protected String field1;

    @DataField(columnName="FIELD2",pos=2)
    protected String field2;

    //  getter/setter

}

public class Format1 extends AbstractBaseFormat {
    @DataField(columnName="FIELD3",pos=3)
    private String field3;
    // getter / setter
}

public class Format2 extends AbstractBaseFormat {
    @DataField(columnName="FIELD3",pos=3)
    private Long field3;
    // getter / setter
}

When i use concrete classe in my route , camel throw an error

java.lang.IllegalArgumentException: The separator has not been defined in the annotation @CsvRecord or not instantiated during initModel. must be specified

Ok, the @CsvRecord annotation is on the abstract class and is not recognized by the Bindy Factory.

But if i put this annotation on each concrete class , i get another exception as Bindy didn't find the first field (pos = 1).

Can i use this kind of model with Bindy csv Dataformat ?

Greg Henry
  • 61
  • 6
  • Hm, I don't get the excpetion. However, I got the problem, that the attributes of `AbstractBaseFormat` are just ignored when writing the CSV for a subclass instance. – Peter Keller Oct 10 '14 at 12:23
  • @Peter : yes , same for me (except the message) , as if annotations from parents can't be reccognized on child – Greg Henry Oct 15 '14 at 16:36
  • It seems that annotations are not inherited by subclasses. See http://stackoverflow.com/a/10082663/86798. – Andy Longwill Jun 15 '16 at 15:20

0 Answers0