On Wednesday, June 25, 2003, at 08:46 AM, Karch, Bertram wrote:
I have an object objA with an attribute objB and objB has a reference back to objA. When I want to marshall objA to XML string I get a stackoverflow cause of an endless loop.
java.lang.StackOverflowError
at java.lang.reflect.Method.invoke(Method.java:310)
at org.exolab.castor.mapping.loader.FieldHandlerImpl.getValue(FieldHandler Impl.java:375)
at org.exolab.castor.xml.handlers.DateFieldHandler.getValue(DateFieldHandl er.java:150)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:190)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDesc riptorImpl.java:885)
at org.exolab.castor.xml.Validator.validate(Validator.java:122)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:250)
Is this a bug in castor ?
Not exactly. It's a problem that Castor is punting on because there's no good default behavior.
I can workaround this problem if I use a mapping file and remove the field objA in objB, but is there another solution ?
If you want to retain the bidirectional relationship, you can map the objA field in objB by reference. (You use the "reference" attribute on <bind-xml> to do this.) This requires that objA have some field that you can use as an object ID. (You use the "identity" attribute on <class> to name the field that contains the identity.)
HTH, Rhett
-- Rhett Sutphin Research Assistant (Software) Coordinated Laboratory for Computational Genomics and the Center for Macular Degeneration University of Iowa - Iowa City - Iowa - 52246 mailto:[EMAIL PROTECTED]
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
