Fix HQL join query