users@glassfish.java.net

RE: Infinite XML Loop

From: Kenneth Clark <kenneth_at_rabiddog.co.za>
Date: Fri, 10 Aug 2007 17:52:01 +0200

I am not understanding what you mean unfortunately.

If I remove references to objects inside objects I effectively break my
model. How would I go about setting references to null if I am doing a
straight "Select o From AccountType o"?

Unless there is a better mechanism to select all the objects I am at a loss
here.

Kenneth Clark
Solution Architect / Lead Developer
Rabid Dog Labs

Tel: +27 11 475 7409
Mobile: +27 82 500 5090
Email: kenneth_at_rabiddog.co.za
Web: http://www.rabiddog.co.za
-----Original Message-----
From: Sanjeeb.Sahoo_at_Sun.COM [mailto:Sanjeeb.Sahoo_at_Sun.COM] On Behalf Of
Sahoo
Sent: Friday, August 10, 2007 13:32
To: users_at_glassfish.dev.java.net
Subject: Re: Infinite XML Loop

That exception typically comes from JAXB marshaling code when it detects
a cycle in the object graph. Are you returning the object from a web
service? Your in-memory object probably has the bidirectional references
set up, this can happen if you traverse the relationships in your code.
So, instead of relying on fetch type, you should explicitly cut the
cycles in the graph by setting some references null.

Thanks,
Sahoo

Kenneth Clark wrote:
>
> Hi guys
>
> I have a bi-directional relationship and everytime I try and fetchAll
> I am getting the error
>
> “com.sun.istack.SAXException2: A cycle is detected in the object graph.
This will cause infinitely deep XML:”
>
> The mapping in the AccountType class is:
>
> @OneToMany(mappedBy = "accountType", fetch=FetchType.LAZY)
>
> private Collection<EntityAccountInformation>
> entityAccountInformationCollection;
>
> And the mapping in the EntityAccountInformation is
>
> @ManyToOne
>
> @JoinColumn(name = "account_type_id", referencedColumnName = "id")
>
> private AccountType accountType;
>
> Do I have to remove the bidirectional relationship to resolve this?
> Why is it ignoring the FetchType?
>
> I enabled the toplink.weaving property (read that it might stop this)
>
> <property name="toplink.weaving" value="true"/>
>
> But nothing seems to be helping.
>
> Any feed back would be great
>
> Thanks
>
> Kenneth Clark
> *Solution Architect / Lead Developer**
> **Rabid Dog Labs*
>
>
> *Tel:* +27 11 475 7409
>
> *Mobile**:* +27 82 500 5090
> *Email:* kenneth_at_rabiddog.co.za <mailto:kenneth_at_rabiddog.co.za>
> *Web: *_http://www.rabiddog.co.za <http://www.rabiddog.co.za/>_
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date:
> 2007/08/09 14:44
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date: 2007/08/09
14:44
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date: 2007/08/09
14:44