... has nothing todo with what im about to tell you. No, really, it dosent. Although, its about the same - a quick how to on how to write SQL JOIN's with nHibernates "super-shitty" HQL
Say heres your bog standard JOIN statement that you want to run:
SELECT * from MODEL INNER JOIN ModelClassTypeMap ON Model.Id = ModelClassTypeMap.ModelID
WHERE ClassTypeId=2 ORDER BY HighestNewRating DESC
You cant simply just rewrite that in HQL. HQL dosent use the "ON" directive. So you have to do multiple FROM statements, then tell it what you want to select. Sound easy? Welp, it isnt:
SELECT model FROM Model model, ModelClassTypeMap classTypeMap WHERE
model.Id = classTypeMap.Model AND classTypeMap.ClassType = ? ORDER BY classTypeMap.HighestNewRating DESC
To me this just seems retarded. You cant copy the sql that youv spent minutes perfecting, but you have to go and rewrite the whole thing so a 3 year old blind child whos been on cocaine for the last 6 months can understand it. Why not just do it so that you can reuse queries that you already have, instead of having to rewrite the whole way you write them? HQL is a poor mans SQL, its shoddy and flaky, and hardly documented.
Happiness is a warm gun.