Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HQL for two tables linked by a relationship table?

 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the really stripped-down essence of two classes


and



and that the relationship table does get filled in with the district-school id mappings,

how would I write the following straight-SQL query
" select aa.name, bb.name FROM districts AS aa
JOIN school_district_relationship AS rr
ON aa.id = rr.id_district
JOIN schools AS bb
ON bb.id = rr.id_school
ORDER BY 1,2
;

in Hibernate's HQL? Nothing I've tried in HQL works except for the simplest " FROM Districts" Trying


I need an HQL query that will generate:
name | name
=================
ALAMEDA | KENNEDY
ALAMEDA | SHRIRE
FREEMONT | TOBIAS
FREEMONT | UNDERWOOD
FREEMONT | WATERFORD

Any hints/suggestions/constructive critisms and especially examples are always greatly appreciated!

TIA,

Still-learning Stuart
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic