[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

join using hibernate hql

Posted on 2007-10-21
1
Medium Priority
?
13,467 Views
Last Modified: 2013-11-24
this is a hibernate question.

I am not able to find sample hql for doing join involving two tables.

table item has a (int) userid, which refers to user table. there is a name attribute in the user table.

I want to do a sorted collection query, in the ascending order of user.name.

the equivalent sql would be
SELECT * FROM item INNER JOIN user ON item.userid=user.userid ORDER BY user.`name`

please help me with the corresponding hql.
0
Comment
Question by:bhomass
1 Comment
 

Accepted Solution

by:
3lIOns earned 150 total points
ID: 20192184
HQL isnt SQL. You dont do 'joins', you navigate the object graph.

I would suggest something like.... "FROM item i WHERE i.user.name = ?" which is like saying "get items where item.getUser().getName().equals(?)"
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

834 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