-->
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.  [ 3 posts ] 
Author Message
 Post subject: Finagling an outer join...
PostPosted: Fri Feb 25, 2005 7:51 pm 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
I'm using Hibernate 3b4.

I currently have a User and UserWidget object (1->N Association), that works great as/is.

Each Widget has a type property (not unique) and an identifie property (is unique).

I'm finding myself needing to find the identifier field in the user's "primary" type widget ALOT. Right now User.getPrimaryWidgetId() has to look at all the widgets and find the right one. I want to improve this.

What I REALLY want is to have Hibernate do an OuterJoin whenever I get User and fill in the primaryWidgetId field in the User class...I dont see how to do that though...

Since using Hibernate 3, I suppose I can "re-map" the 1->Many association of the UserWidget class (Essentially make a "PrimaryWidget" class which is UserWidget + appropriate HQL/SQL) and a 1-1 association to it from User...but that's not quite what I want.

Can I do this? I'm sure I'm being dense, but I have looked and didn't see my answer (I fully expect an annoyed response and a pointer to the docs showing what I missed/misread).

TIA

[/i]

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 8:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use a <formula> property mapping with a subselect.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 26, 2005 12:49 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
Yep. Does the trick marvelously.

Thanks, Gavin.

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.