Thank you, It seems I need to change the setter and getter methods and then enable the setting in castor.properties to generate the accessor methods from the XML Schema.
Cheers Neil -----Original Message----- From: Martin, Margaret [mailto:[EMAIL PROTECTED]] Sent: 19 November 2002 16:49 To: [EMAIL PROTECTED] Subject: Re: [castor-dev] How do I define an array collection for JDO? Neil, You'll need to add additional setters/getters that utilize either another collection type for the collection (ArrayList or Vector). Then change the mapping to something like: <class name="com.novobase.castor.Atoms" identity="id" depends="com.novobase.castor.Minimol" key-generator="MAX"> <description>Atoms</description> <map-to table="atoms"/> <field name="id"> <sql name="id"/> </field> <field name="atom" type="com.novobase.castor.Atom" collection="ArrayList" set-method="getAtomsList" get-method="getAtomsList"> <sql many-key="parentId"/> </field> </class> HTH - Margaret -----Original Message----- From: Neil Blue [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 19, 2002 4:16 AM To: [EMAIL PROTECTED] Subject: [castor-dev] How do I define an array collection for JDO? Hello, I am using Castor to unmarshall and store XML files. I have managed this for a subset of elements from my schema so far. However I have come across a problem trying to store collections of objects. Here is an extract from my schema: <xs:complexType name="atomsType"> <xs:sequence> <xs:element name="atom" type="atomType" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="id" type="xs:integer"/> </xs:complexType> This creates an 'AtomsType' class with 'Atom[] getAtom()' and 'setAtom(Atom[])' methods. This works fine till I try to store this array. Here is my mapping.xml entry: <class name="com.novobase.castor.Atoms" identity="id" depends="com.novobase.castor.Minimol" key-generator="MAX"> <description>Atoms</description> <map-to table="atoms"/> <field name="id"> <sql name="id"/> </field> <field name="atom" type="com.novobase.castor.Atom" collection="array"> <sql many-key="parentId"/> </field> </class> But the error I get when I go to store the object is: [junit] Testcase: testJDO took 1.035 sec [junit] Caused an ERROR [junit] The return type for method public com.novobase.castor.Atom[] com.novobase.castor.AtomsType.getAtom() does not match the declared field type [Ljava.lang.Object; [junit] org.exolab.castor.mapping.MappingException: The return type for method public com.novobase.castor.Atom[] com.novobase.castor.AtomsType.getAtom() does not match the declared field type [Ljava.lang.Object; [junit] at org.exolab.castor.persist.FieldMolder.findAccessor(Unknown Source) Please could anyone tell me if my mapping is wrong or if there is a better way to do this. Thank you Neil ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
