wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets 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 c.id = 1 AND vilstreets.house member of cstreets.house order by count(vilstreets.house)";

I agree. Here's the link: http://aspose.com/file-tools
subject: Hibernate HQL-Query
Similar Threads
LinkedList & Add Method?
Problem in hibernate join result
interface & Comparing Strings
Send PUT to different RESTful webservice running on the same local Tomcat?
assignment help