-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Circular relationship between objects.
PostPosted: Thu Sep 28, 2006 2:08 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
Hi All,
As per DB design i have circular relationship between objects.

for eg,
take,object1,object2 and object3

object1 has many to one relationship with object2 and object2 has many-to-one relationship with object3 and object3 has many-to-one relationship with object1.

Is this mapping scenerio is possible in Hibernate?

Note: all objects having bidirectional relationship between them.
I tried for this mapping and getting Memory out of error.

Help me to solve this issue.


Any sample code please....

Regards
Shanmugam.N


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:23 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I think that many-to-one is always eagerly loaded, at least in 3.0.x and earlier. So no, that's not a feasible mapping. If you change at least one of the associations to many-to-many unique="true" lazy="proxy" (or lazy="true", if you're using an older version of hibernate), then you can take advantage of lazy loading. That will allow you to implement the relationships that you're describing.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 11:24 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
hi tenwit,
Thanx for ur reply.I have solved this problem by set fetch="select" in one many-to-one mapping.(previously it was fetch="join").

we cant use unique="true" for many-to-one(if u use it will take as one-to-one).

i want to know is there any other way to solve this issue..

Thanks in Advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 4:37 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
My suggestion was to use "many-to-many unique="true"", not "many-to-one unique="true"". However, I'll withdraw that suggestion: unqiue many-to-many is one-to-many, not many-to-one. Oh well.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.