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 relationship
PostPosted: Thu May 20, 2004 12:07 am 
Newbie

Joined: Wed May 19, 2004 11:50 pm
Posts: 9
Let us take the classic Order-Customer relationship.
Order always will have a customer.
Hence relationship is Many to one from Order to Customer.
All is fine . I want to avoid the left outer join and do a
simple inner join since the relationship is mandatory.
Is there a way to do this?
I tried to specify not-null but did not work

<many-to-one name="customer" column="customer_id" not-null="true" />


If I add a criteria like customer.name='John' then Hibernate automatically does the inner join and not the left outer join

thanks


Top
 Profile  
 
 Post subject: Is this possible?
PostPosted: Thu May 20, 2004 3:19 pm 
Newbie

Joined: Wed May 19, 2004 11:50 pm
Posts: 9
If the elationship is mandatory how can I avoid the outer join
thanks


Top
 Profile  
 
 Post subject: I guess this is not possible
PostPosted: Fri May 21, 2004 12:09 pm 
Newbie

Joined: Wed May 19, 2004 11:50 pm
Posts: 9
Anyone? Hibernate team can you confirm please ..

I have a Many to One relationship which is guaranteed .
For example Order always has Customer.
Why is an OuterJoin done here ? Is it necessary? How can I avoid it?(By specifying something in the Mapping?)
I want to avoid the outerjoin since in some cases it does not make use of index and henc ecan create performance issue.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 2:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Are you talking about on load()? There there is no way to do this currently.

During queries, you can always explicitly specify the manner in which the joins are done using the various join strategies. Navigating a relation like you mention with the "select o from Order as o where o.customer.something..." syntax does an implicit inner join for you. The explicit way is to say "select o from Order as o inner join fetch o.customer as c". Check out the docs on HQL for more info on this.


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.