This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate HQL-Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate HQL-Query" Watch "Hibernate HQL-Query" New topic

Hibernate HQL-Query

Andi Wick

Joined: Mar 22, 2013
Posts: 1
I have got 4 classes: Village, City, Street, House

Each village has a List of Streets
private List< Street > streets = new ArrayList< Street >();

Each city has a List of Streets
private List< Street > streets = new ArrayList< Street >();

And each Street has a single house
private House house;

Now I want to find all Villages, that contain houses that are also contained in a specific City (lets say the city with id=1) and sort the result set of Villages by the amount of matching houses. (Find the Villages best fitting [sharing the same houses] to a City)

I wrote the following HQL-Query but it always delivers a result set of size 1 :/ What is wrong ?

SELECT DISTINCT vil from Village as vil left join vil.streets as vilstreets, City as c left join c.streets as cstreets where = 1 AND member of order by count(";

I agree. Here's the link:
subject: Hibernate HQL-Query
It's not a secret anymore!