1

I have two classes CommonRequest and AccountRequest

@FixedLengthRecord(paddingChar=' ',ignoreTrailingChars=true)
public class CommonRequest {

@Id
private String corelationID;

@DataField(pos=1,length=8)
private String cmNumber;

@DataField(pos=2,length=16)
private String accountNumber;

}

And AccountRequest.java

@FixedLengthRecord(paddingChar=' ',ignoreTrailingChars=true)
public class AccountRequest extends CommonRequest {

@Id
private String corelationID;

@DataField(pos=3,length=14)
private String accountType;

@DataField(pos=4,length=15)
private String accountLocation;

}

When I tries to unmarshall a record like cmNumberaccountNumberaccountTypeaccountLocation

It unmarshall common request properly but when i tries to unmarshall AccountRequest it takes the position from start instead of continuing it from the position left in common request.

And this mismatches whole fields in the AccountRequest.

Vaibhav Bhootna
  • 166
  • 2
  • 15

2 Answers2

0

Change the position to match the lengths , but still you will not have the fields in the base class set , they will be null, but the child class fields will be set . Check this site to see how it can be done.http://people.apache.org/~dkulp/camel/bindy.html

Sundar
  • 564
  • 3
  • 7
  • tried changing the position , it actually skip 2 characters as we gave pos=3 in child class. It was working fine in 2.13.0 version but now in 2.16.0 it is giving me an issue – Vaibhav Bhootna Dec 29 '15 at 19:54
  • Provide the actual position number in the child class like pos=25 in the place of pos=3. – Sundar Jan 01 '16 at 16:47
0

Consider this as text record 01 32 Sundar Moorthy

@FixedLengthRecord(length = 20,ignoreTrailingChars=true)
public class Employee {
@DataField(pos = 1, length = 2)
private int serialNo;
@DataField(pos = 4, length = 2)
private int age;
@DataField(pos = 7, length = 6)
private String firstName;
....getters and setters
}

@FixedLengthRecord(length=20)
public class Employee2 extends Employee{
@DataField(pos=14, length=7)
private String lastName;
....
getters and setters..
}

Now if you use Camel to unmarshal the text file using Employee class the result will be that the serial number and age and firstname will be set to model. 132Sundar and if you use camel to unmarshal the text file using Employee2 class the result will be that the lastname will be set to model. Moorthy

This is with camel 2.16.0 , please let me know if have any further issues, but the fields in the base class will not be set.

Sundar
  • 564
  • 3
  • 7