Werner, Thanks a lot for the quick response. I've added those attributes and the marshalling goes smoothly.
Sadly when trying to unmarshall I get this exception: java.lang.ClassCastException: com.linkedin.osc.model.EmailHashEntry On Wed, May 26, 2010 at 12:57 PM, Werner Guttmann <[email protected]>wrote: > 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 >> >>

