users@glassfish.java.net

RE: A cycle is detected in the object graph

From: Kenneth Clark <kenneth.clark_at_skyetech.co.za>
Date: Tue, 6 Nov 2007 01:06:10 +0200

Thanks, I suddenly had an idea about detaching the objects and so I tried
the em.clear then setting the references to null.

Thanks very much for that

________________
Thanks and regards

Kenneth Clark
Solutions Engineer


Tel: 27 11 679 3075
Mobile: 27 (0) 84 583 1348
Email: kenneth.clark_at_skyetech.co.za
Website: http://www.skyetech.co.za


-----Original Message-----
From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
Sent: 06 November 2007 00:57
To: users_at_glassfish.dev.java.net
Subject: Re: A cycle is detected in the object graph

You need to disconnect objects after/when they are detached. Either use a
non-tx
query, or close/clear em before nullifying the references.

Regards,
-marina

Kenneth Clark wrote:
> I am faced with quite a challenge here.
>
>
>
> I have the objects ClientProfile and Subscription:
>
>
>
> The ClientProfile contains a collection of Subscriptions:
>
> ______________________________________________________________________
>
> public class ClientProfile implements Serializable {
>
>
>
> @OneToMany(mappedBy = "clientProfile", cascade={CascadeType.MERGE,
> CascadeType.PERSIST})
>
> private List<Subscription> subscriptionCollection;
>
>
>
> public ClientProfile() {
>
> }
>
>
>
> public List<Subscription> getSubscriptionCollection() {
>
> return subscriptionCollection;
>
> }
>
>
>
> public void setSubscriptionCollection(List<Subscription>
> subscriptionCollection) {
>
> this.subscriptionCollection = subscriptionCollection;
>
> }
>
> }
>
> ______________________________________________________________________
>
>
>
> public class Subscription implements Serializable {
>
> @ManyToOne
>
> @JoinColumn(name = "client_profile_id", referencedColumnName = "id")
>
> private ClientProfile clientProfile;
>
>
>
> public Subscription() {
>
> }
>
>
>
> public ClientProfile getClientProfile() {
>
> return clientProfile;
>
> }
>
>
>
> public void setClientProfile(ClientProfile clientProfile) {
>
> this.clientProfile = clientProfile;
>
> }
>
> }
>
>
>
> Now if I want to push this down via a webservice, everytime I try I get
> “A cycle is detected in the object graph”. Now I understand why this is
> happening but then I try and set the client profile inside the
> subscription collection to Null (to break the graph) I am getting a
> constraint failure because of the foreign key. It is as if when I set
> the client profile value inside subscription it wants to perform an
update.
>
>
>
> Does anyone know how to get round this? How do I send this to my client
> app with the clientProfile and it’s subscription list in tact?
>
> ________________
>
> Thanks and regards
>
>
>
> *Kenneth Clark*
>
> Solutions Engineer
>
>
>
> ShadowLogo.png
>
> *Tel:** *27 11 679 3075
>
> *Mobile:** *27 (0) 84 583 1348**
>
> *Email:** *_kenneth.clark_at_skyetech.co.za
> <mailto:kenneth.clark_at_skyetech.co.za>_
>
> *Website:** *http://www.skyetech.co.za**
>
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.15.22/1111 - Release Date:
> 2007/11/05 04:36
>

---------------------------------------------------------------------
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.503 / Virus Database: 269.15.22/1111 - Release Date: 2007/11/05
04:36
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.22/1111 - Release Date: 2007/11/05
04:36