I have a bidirectional many-to-many relationship between Category and
Item.  I'm trying to write an efficient query that, given a category's
ID, will initialize all items belonging to that category as well as
initialize each of those item's Categories collections.

The HQL query I wrote is:
  "from Item i left join fetch i.Categories cats where :cid in
elements(cats)"

I'm no HQL expert, so I should first ask: does this query looks okay?

In any case, the resulting SQL is rather funky:

select * where @p0 in (select category2_.CategoryID from eft outer
join Category_Item categories1_ on item0_.ID=categories1_.ItemID left
outer join Category category2_ on
categories1_.CategoryID=category2_.ID where

For readability, I replaced some details in the SELECT clause with a
star.  I don't see what comes after the last "where" since Visual
Studio's exception dialog box (I think) cut it off.  Anyway, notice
that "left" is even spelled as "eft".  What happened here?

Reply via email to