Hello,

 

I am trying to map an xml data file into java objects and it seems as if the
nested collections are not being populated at all.

 

Here is a snippet of the mapping file (class names truncated for brevity):
<mapping>
    <class name="Data2">
        <field name="type" type="string">
            <bind-xml name="type" node="attribute"/>
        </field>
        <field name="tuples" type="DataTuple" collection="arraylist">
            <bind-xml name="tuple" location="tuples"/>
        </field>
        <field name="dataSource" type="DataSource">
            <bind-xml name="dataSource"/>
        </field>
    </class>
    
    <class name="DataTuple">
        <field name="name" type="string">
            <bind-xml name="name" node="attribute"/>
        </field>
        <field name="type" type="string">
            <bind-xml name="type" node="attribute"/>
        </field>
    </class>
    
    <class name="DataSource">
        <field name="user" type="string">
            <bind-xml name="user" node="attribute"/>
        </field>
        <field name="pass" type="string">
            <bind-xml name="pass" node="attribute"/>
        </field>
        <field name="connectionUrl" type="string">
            <bind-xml name="connectionUrl" node="element"/>
        </field>
    </class>
</mapping>

 

Here is a snippet of the data file:
<data>
    <dataObject type="temperature">
        <tuples>
            <tuple name="temperature" type="int" />
        </tuples>
        <dataSource user="user" pass="pass">
            <conectionUrl>jdbc:postgresql://localhost/db</conectionUrl>
        </dataSource>
    </dataObject>
    <dataObject type="power">
        <tuples>
            <tuple name="power" type="int" />
        </tuples>
        <dataSource user="user" pass="pass">
            <conectionUrl>jdbc:postgresql://localhost/db</conectionUrl>
        </dataSource>
    </dataObject>
</data>

 

The output shows that the object has not been initialised properly i.e. the
arraylist is empty

WMData2 [type=temperature, ArrayList(size=0) [], wmDataSource=null]

The object DOES have the type correctly initialised.

 

I have tried tweaking the mapping file with no success and have re-read the
instructions(!)

 

What am I missing here, please? Any more things I can try?

 

Cheerio,

Nic Hemley

 

Reply via email to