File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate HQL-Query

 
Andi Wick
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic