Hi,

On 26.05.2010 21:39, pablo fernandez wrote:
Guys,

I have this Xml:

<hashedAddresses>
   <personAddress index='1'>
     <hashedAddress>asdfasdf</hashedAddress>
     <hashedAddress>asdfasdf</hashedAddress>
     <hashedAddress>asdfasdf</hashedAddress>
   </personAddres>
   <personAddress index='2'>
     <hashedAddress>asdfasdf</hashedAddress>
     <hashedAddress>asdfasdf</hashedAddress>
     <hashedAddress>asdfasdf</hashedAddress>
   </personAddres>
</hashedAddresses>

That I want to unmarshall in this class:


public class EmailHashEntry {

   private int index;
   private List<String>  hashes;

   public EmailHashEntry() {

   }

   public void setHashes(List<String>  hashes) {
     this.hashes = hashes;
   }

   public void setIndex(int index) {
     this.index = index;
   }

   public List<String>  getHashes() {
     return hashes;
   }

   public int getIndex() {
     return index;
   }
}

Using this MAPPING:

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "
http://castor.org/mapping.dtd";>
<mapping>
   <class name="com.linkedin.osc.model.EmailHashEntry">

     <map-to xml="hashedAddresses"/>

       <field name="index">
          <bind-xml name="index" node="attribute" />
       </field>

       <field name="hashes">
         <bind-xml name="hashAddress" location="personAddresses"
node="element" />
       </field>

   </class>
</mapping>


PROBLEM:

java.lang.IllegalArgumentException: list is not a valid
FieldMappingCollectionType

I adding "collection='arraylist'" to the mapping and got a NPE.
Well, you will need to specify two things in your <field> mapping for 'hashes'. Its type: string and that it is a collection, using e.g. arraylist as default type.

I hope this helps.

Werner

Thanks


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to