Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Joins in HQL

Posted on 2009-05-10
7
Medium Priority
?
885 Views
Last Modified: 2012-06-27
Hi,
I want to get data from two table by using a join. Since I am using Hibernate, I want to use HQL. Can someone please help me with writing joins in HQL?

Thanks.
0
Comment
Question by:cuttieveenz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24351026
establish the relationship using hibernate annotations or in the .hbm file and then do a normal hql to fetch the records which would automatically fetch the related records based on the join condition.

-Murali*
0
 
LVL 46

Accepted Solution

by:
tbsgadi earned 500 total points
ID: 24352601
Have a look at the following:

http://docs.huihoo.com/hibernate/hibernate-reference-3.2.1/queryhql.html
At the bottom there are examples

Good Luck!

Gary
0
 
LVL 1

Assisted Solution

by:mohgupta
mohgupta earned 500 total points
ID: 24383007
You first need to the mapping file like hibernate.hbm.xml and then need to declare class for each table in dtatabase ,you wish to use. In config file define database connection properties "*.cfg.xml"

 In mapping file specify the relationship between class and the table i.e mapping class to table. For using joins on tables you need to specify relationships like "one to one", "one to many".

To create a query and execute you can write some thing like this:
 getSession().createquery("from class1,class2 where para1: =para2");
To save or update call -
getsession.saveorUpdate(class1);
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24620680
The question was "Can someone please help me with writing joins in HQL?"

Certainly in the link I gave there were enough examples to get the auther started.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question