-->
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: Many-to-one Lazy??
PostPosted: Fri Oct 24, 2003 2:34 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
Hi-

I have a situation modeling situation as follows:


Store(1)->Product(*)

Component(1)->Product(*)


So in both cases, I have a one-to-many relationship mapped from the parent to the Product (bidirectional).

This works fine, when I retrieve the collection of Products from one Parent, the SQL that gets generated seems to get not only the child obects, but also the other parent objects of those children.


In other words, if i first retreive a child object which contains a Many-to-one mapping back to its parent, the parent seems to be auto-retreived also.

The issue is that if you have multiple hierarchy levels, and you begin by retreiving the lowest level, the entire chain seems to be retreived.

Is this expected behavior? Is there a way to make many-to-one relationship lazy?

Thanks,
Brandon


Top
 Profile  
 
 Post subject: Re: Many-to-one Lazy??
PostPosted: Fri Oct 24, 2003 3:32 pm 
Regular
Regular

Joined: Tue Oct 14, 2003 11:11 pm
Posts: 62
Location: Brasil/Curitiba
bridenour wrote:
Is there a way to make many-to-one relationship lazy?


yes, I asked about that once, take a look in this post:
http://forum.hibernate.org/viewtopic.php?t=924851

_________________
Ricardo Lecheta


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 3:36 pm 
Newbie

Joined: Tue Oct 21, 2003 3:41 am
Posts: 5
Location: Belgium
Brandon,

This is indeed the default behaviour.

There are multip[/b]le ways of tweaking this.
The way we do it is by specifying a proxy for the parent class. (In .hbm.xml specify in the class-tag proxy="the.package.for.this.class.ClassName" - If you're using xdoclet it's @hibernate.proxy="again.a.long.text.about.package.and.ClassName")

Also look at the docs in section "11.1. Proxies for Lazy Initialization".

I believe there are other ways of tweaking this as well.. But I don't know the details, and a quick scan in the docs didn't reveal anything..

Kind regards,

Dimitry D'hondt

_________________
Dimitry D'hondt
IT Architect - Real Software n.v.
http://www.realsoftware.be

Author of 'Smile' an open-source JaveServer Faces implementation. (http://smile.sourceforge.net)


Top
 Profile  
 
 Post subject: thanks
PostPosted: Fri Oct 24, 2003 3:43 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:02 pm
Posts: 27
Location: New York, NY
thanks for the response...i'm going to use proxies, as that seems to be the way others are addressing it as well.

Brandon


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.