-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL-Query: Compare and get ordered Result
PostPosted: Mon Mar 25, 2013 3:28 am 
Newbie

Joined: Mon Mar 25, 2013 3:26 am
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)";


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.