File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate HQL-Query" Watch "Hibernate HQL-Query" New topic
Author

Hibernate HQL-Query

Andi Wick
Greenhorn

Joined: Mar 22, 2013
Posts: 1
Hey,
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