Title: how to write mapping for collections

Hi, I am wondering how I can write mapping file of collections. Basically I have ObjectA and ObjectB, I put them into collections such as ArrayList(which will be the root).

How do I write mapping file for the root object which is an arraylist?

I tried this it did not work:

       ArrayList list = new ArrayList();
        list.add(objectA);
        list.add(objectB);
        StringWriter sw = new StringWriter();
        Marshaller marshaller = new Marshaller(sw);
        marshaller.setMapping(mapping);
        marshaller.marshal(list);
        System.out.println(sw.toString());
The DOS console printout "<arrayList/>"

In the mapping.xml I have:
<mapping>
<class name="ObjectA">
 <map-to xml="ObjectA"/>  
....
<class name="ObjectB">
 ....
</class>
</mapping>


Thanks.

Reply via email to