-->
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.  [ 2 posts ] 
Author Message
 Post subject: two joins in single query with hibernate
PostPosted: Thu Sep 29, 2005 5:29 pm 
Newbie

Joined: Thu Mar 17, 2005 8:15 pm
Posts: 19
I have following table structure.

(1)
Table Name: Orders
requestedById
AssignedTO

(2)
Employee Table
employeeID
employeeName.

Now I have to retrieve names of requestedById and assignedTO in single query. I defined it as many-to-one from orders to employee, but it looks like I wrongly mapped. Obviously, I dont want to execute two queries to get the names. Any help is appreciated.

Thanks & Regards
Nagesh G


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: hql
PostPosted: Thu Sep 29, 2005 7:01 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
HQL: select o.requestedBy.name, o.assignedTo.name from Order o

Note:
- actual property names depend on your mapping;
- number of SQL queries depends on fetching strategies specified in mapping file
http://www.hibernate.org/hib_docs/v3/re ... -manytoone

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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