• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HQL for two tables linked by a relationship table?

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He does not suffer fools gladly. But this tiny ad does:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic