posted 16 years ago
How does JAXB 2 understand inheritance? I have a class Student which have two derived class HostelStudent and DayStudent. One property is different between 2 derived class i.e roomNo (HostelStudent) and lockerNo(DayStudent).
xml structure for unmarshall is
<blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre name="code" class="core"><font size="2">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Student>
<rollNo>0</rollNo>
<name>Darren</name>
<className>V</className>
<englishMarks>90</englishMarks>
<roomNo>121</roomNo>
</Student>
</font></pre><hr></blockquote>
I want when input xml will have element < lockerNo> then JAXB should create object DayStudent and when there is <roomNo> it should create object of HostelStudent.
Or can we make one field a descriptor field? Like if rollNo (which is in basse class) is 0 then object will be HostelStudent else DayStudent.
I cannot change the xsd or input xml structure
Thanks in advance.
[ July 24, 2008: Message edited by: Sandeep Ghosh ]