OK, I missed a mail from Dennis in the archive: http://www.mail-archive.com/jibx-users%40lists.sourceforge.net/msg01387.html - the id value in deed has to be a String.
Sorry for the spamming :-( Alexander > -----Ursprüngliche Nachricht----- > Von: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Auftrag von Niemann > Alexander > Gesendet: Mittwoch, 5. Oktober 2005 09:39 > An: [email protected] > Betreff: AW: [jibx-users] OutOfMemoryError marshalling a > parent/child-relationship > > > I've got a working version now - thank you! > > Unfortunately the solution leads to another question: Does > the identifier field really has to be a String? Originally my > "id" property is a BigDecimal. Using it as an identifier > results in a compilation error: > > [bind] Error: ID property must supply a java.lang.String > value for value element at ... > > So I added a String representation of "id" called "idStr" to > DealHead. It's automatically set when "id" is set so the > values are always equal. Using this property as identifier > works, but I don't find it very sexy to have "idStr" in my model. > > Is there any other way? I couldn't find anything about this > in the documentation. > > Alexander > > > -----Ursprüngliche Nachricht----- > > Von: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] Auftrag von Dennis > > Sosnoski > > Gesendet: Samstag, 1. Oktober 2005 06:30 > > An: [email protected] > > Betreff: Re: [jibx-users] OutOfMemoryError marshalling a > > parent/child-relationship > > > > > > Hi Niemann, > > > > You need to do something about the circular references for > > this to work > > properly. The easiest approach is to make the id property of > > DealHead an > > identifier, with ident="def", then make the dealHead field of > > DealDetail > > a reference, with ident="ref". That should give you what you want. > > > > Note that it's more common for XML to use nesting to indicate > > ownership, > > so that typically the XML representation of the DealDetails > would not > > actually have a link back to the parent DealHead. To make that work > > properly you'd need a way of setting the references when > > unmarshalling. > > One easy way is to define an addDetail() method to the > > DealHead class. > > This method would set the DealDetail dealHead field to > > "this", then add > > the DealDetail to the HashSet. > > > > - Dennis > > > > Niemann Alexander wrote: > > > > > Hello everybody, > > > > > > I encountered an error marshalling the following class: > > > > > > public class DealHead { > > > private Long id; > > > private Set dealDetails = new HashSet(); > > > .... > > > } > > > > > > The collection dealDetails contains instances of > > DealDetail, whereas a > > > DealDetail contains a reference back to it's parent: > > > > > > public class DealDetail { > > > private Long id; > > > private DealHead dealHead; > > > ... > > > } > > > > > > My binding file looks like this: > > > > > > <mapping class="de.ava.kas.model.DealHead" name="deal-head"> > > > <value name="id" field="id" usage="optional"/> > > > <collection field="dealDetails" usage="optional" > > > item-type="de.ava.kas.model.DealDetail" type="java.util.HashSet"/> > > > ..... > > > </mapping> > > > <mapping class="de.ava.kas.model.DealDetail" name="deal-detail"> > > > <value name="id" field="id" usage="optional"/> > > > <structure field="dealHead" usage="optional"></structure> > > > ..... > > > </mapping> > > > > > > Now, when I try to create the XML from my DealHead > objects I get an > > > error: java.lang.OutOfMemoryError: Java heap space > > > > > > I guess that JiBX gets into an endless loop trying to solve the > > > bi-directional relationship between DealHead and DealDetail (head > > > contains detail containg head containing detail and so on). > > As soon as > > > I leave the collection DealHead.dealDetails empty or remove the > > > mapping from my binding it just works just fine. > > > > > > Are there any suggestions how this problem can be avoided without > > > changing the classes? Did I make any mistakes in my binding? > > > > > > Thanks in advance, > > > Alexander > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, downloads, > > discussions, > > and more. http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > jibx-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/jibx-users > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, > discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > jibx-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
