I get what sounds like the exact same issue of the extra comma appearing before a left outer join, resulting in an SQLGrammarException. The SQL generated by Hibernate 2 did not have the comma.
I'm using MySQL 4.1 and originally tried hibernate 3.0.5 and then after reading this thread I tried the latest source from CVS. Unfortunately I still get the same issue.
The bug is marked as fixed in JIRA (
http://opensource.atlassian.com/projects/hibernate/browse/HHH-554).
Here is the generated SQL
select spc.category, count( spc.category ) from SearchableProductCategory as spc
left join spc.searchableProduct sp inner join spc.category c inner join c.categoryHierarchiesByCategoryId ch where ch.co
mp_id.categoryTypeId = 'PRODUCT_CATEGORY' and sp.id in ( select sp.id from SearchableProduct sp left join sp.products p
left join sp.searchableProductCategories spc1 left join spc1.category cat1 left join cat1.categoryHierarchiesByCategoryI
d hi1 inner join p.channelPricings cp inner join cp.channel c where ((hi1.categoryType.id = 'PRODUCT_CATEGORY') and ((ca
t1.categoryId = 'CAT_WASHINGMACHINES'))) and (sp.isVisible = 'T') and (c.name = 'PWS') and (cp.isVisible = 'T') ) and no
t spc.comp_id.category in ('CAT_WASHINGMACHINES') group by spc.category order by count( spc.category ) desc
16:16:48,162 INFO [STDOUT] Hibernate: select searchable0_.category as col_0_0_, count(searchable0_.category) as col_1_0
_, category2_.category_id as category1_, category2_.name as name194_, category2_.short_description as short3_194_, categ
ory2_.long_description as long4_194_, category2_.small_image as small5_194_, category2_.large_image as large6_194_, cate
gory2_.opt_img1 as opt7_194_, category2_.opt_img2 as opt8_194_, category2_.opt_img3 as opt9_194_, category2_.version as
version194_, category2_.created_dts as created11_194_, category2_.created_by as created12_194_, category2_.last_updated_
dts as last13_194_, category2_.last_updated_by as last14_194_ from searchable_product_category searchable0_ left outer j
oin searchable_product searchable1_ on searchable0_.id=searchable1_.id, category category2_ inner join category_hierarch
y categoryhi3_ on category2_.category_id=categoryhi3_.category_id where searchable0_.category=category2_.category_id and
categoryhi3_.category_type_id='PRODUCT_CATEGORY' and (searchable1_.id in (select searchable5_.id from searchable_produc
t searchable5_, product products6_, channel_pricing channelpri10_, channel channel11_, searchable_product_category
searc
hable7_, left outer join category category8_ on searchable7_.category=category8_.category_id, category_hierarchy categor
yhi9_ where channelpri10_.id=channel11_.id and products6_.sku=channelpri10_.sku and categoryhi9_.category_type_id='PRODU
CT_CATEGORY' and category8_.category_id='CAT_WASHINGMACHINES' and searchable5_.is_visible='T' and channel11_.name='PWS'
and channelpri10_.is_visible='T')) and not (searchable0_.category in ('CAT_WASHINGMACHINES')) group by searchable0_.cat
egory order by count(searchable0_.category) desc limit ?