This one time, at band camp, Barley said:
B>Has anyone successfully gotten a field containing some
B>sort of array of arbitrary custom objects to work? I'm
B>talking about a mapping that looks like:
B><field name="items" type="mypackage.Item"
B>collection="array">
B> <sql name="item_id" many-key="subscale_id"/>
B> </field>
B>
B>In other words, there's a 'subscale' table with a
B>subscale_id, an 'item' table with an item_id and the
B>foreign key subscale_id. A Subscale object has a
B>property that is an array of Item's.
B>
B>Castor seems to expect an array of java.lang.Object's,
B>as I get this error:
B>org.exolab.castor.mapping.MappingException: The return
B>type for method public mypackage.Item[]
B>mypackage.Subscale.getItems() does not match the
B>declared field type [Ljava.lang.Object;
B>
B>I can add in some methods to return my collections as
B>Vector's (I get Vector collection types to work no
B>problem), but that's sort of messy and I'd rather see
B>the array collection type work. The documentation seems
B>to indicate that it should work the way I am expecting,
B>and I use array collections extensively in Castor XML
B>mapping. Am I missing something?
Gregg,
AFAIK, arrays of a *particular* object type work just fine. The
problem described above seems to be a product of trying to hold
*arbitrary* object types in the array when the mapping informs
Castor that the array should only contain objects of type mypackage.Item.
If Castor finds that an object not of the type mypackage.Item exists
in the array, it will throw the error above.
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev