I have an interesting un-marshalling problem.
 
Long story short I have an object which may contain children of the same type.
When I marshall the graph, the XML produced is correct. When I un-marshall the XML,
I only get the parent objects; the children of the same type contained within are lost.
 
Hopefully the mapping and result files will help. I left out the calls that are not relevant to this
problem.
 

Mapping File1,
 
<mapping>
 <include href=""/>
 <include href=""/>
<class name="com.talavara.viper.domain.benefit.Benefit" >
  <map-to xml="Benefit"/>
   <field name="BenefitOption" get-method="getBenefitOptions" set-method="setBenefitOptions"
   type="com.talavara.viper.domain.benefit.BenefitOption" collection="collection">
       <bind-xml name="BenefitOption" node="element"/>
   </field>
</class>
</mapping>
 
 
 
Mapping File2 included within file 1
<mapping>
   <include href=""/>
   <class name="com.talavara.viper.domain.benefit.BenefitOption" >
   <map-to xml="BenefitOption"/>
   <field name="BenefitOption" get-method="getSubOptions" set-method="setSubOptions"
  type="com.talavara.viper.domain.benefit.BenefitOption" collection="collection">
     <bind-xml name="BenefitOption" node="element" />
   </field>
</field>
</class>
</mapping>
 
 
 
Resulting XML:
 
<Benefit BenefitClassId="15" BrokerBrokerFederalTaxId="broker tax id"
    BrokerName="broker name" ContractIdentifier="" Id="-1"
    IsOwned="false" Name="name" OrganizationId="DEV"
    TPAFederalTaxId="TPA TAX ID" TPAName="TPAName" VendorId="1">
    <BenefitOption Description="Benefit Option" Id="one-main" Selected="false">
       <BenefitOption Description="Benefit Option" Id="one-l21" Selected="false">                       
           <BenefitOption Description="Benefit Option" Id="one-l31" Selected="false">
                <Amount Amount="100.0" Id="BA-1057006212344-978945480">
                   <Type Description="Premium" Name="PREMIUM"/>
                 </Amount>
                <Amount Amount="100.0" Id="BA-1057006212344-978945480">
                   <Type Description="Premium" Name="CONTRIBUTION"/>
                 </Amount>
 

When I un-marshall the xml I only get the top tier BenefitOption objects; each
collection of objects that may be contained witihin are null(Amounts/Options) even though they exist
within the XML.
 

Any help is greatly appreciated since I'm on the verge of doing the bindings the old fashion way ;-()
 
 
 
 
 
 
 
 

Reply via email to