I need to sort pojo of different data type like Student,employee,patient using age and store it into array. Then write it to flat file using beanio.
By json i am sending request which can have array of student,employee and patient .I have 3 pojo at java side like student,employee,patient to store data from json request.
i am able to merge and then sort all array of objects like student,employee,patient into single array of class which is base class of student,employee,patient like Human. Human class i have to make so i can sort all 3 child class using Comparator by property age.
class SortbyAge implements Comparator<Human>
{
// Used for sorting in ascending order of
// age
public int compare(Human a, Human b)
{
return a.getAge() - b.getAge();
}
}
By here everything is fine . I am able to sort data depending on age and store it into Human Array.
problem is when i am writing sorted data to flat file using beanio .
**when i am writing data to Flat file i am getting exception below exception
org.beanio.BeanWriterException: Bean identification failed: no record or group mapping for bean class 'class [Lcom.amex.ibm.model.Human;' at the current position**
i have written all 4 tags into xml file like below.
<record name="student" class="com.amex.ibm.model.Student" occurs="0+" maxLength="unbounded">
<field name="name" length="3"/>
<field name="age" length="8"/>
<field name="address" length="15"/>
</record>
<record name="employee" class="com.amex.ibm.model.Employee" occurs="0+" maxLength="unbounded">
<field name="name" length="3"/>
<field name="age" length="8"/>
<field name="address" length="15"/>
</record>
<record name="patient" class="com.amex.ibm.model.Patient" occurs="0+" maxLength="unbounded">
<field name="name" length="3"/>
<field name="age" length="8"/>
<field name="address" length="15"/>
</record>
<record name="human" class="com.amex.ibm.model.Human" occurs="0+" maxLength="unbounded">
<field name="age" length="3"/>
</record>
How to define Parent class mapping in bean IO??