HQL 查询语句问题? 朋友们帮忙看一下..

执行这天Hql语句时报如下错误:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: and near line 1, column 164:

HQL语句如下:

from BtripApplication btrip left join fetch btrip.applicationItemList btripItem
inner join btrip.organizationUnit orgUnit where

and ((btr.employee.ouCode like :code1 or btr.employee.ouCode like :code2)
and (btr.employee.ouCode like :orgUnitSearchPath or btr.employee.ouCode like :orgUnitSearchPath||'/%'))
and orgUnit.type is null or orgUnit.type =:orgGrounp
and :year is null or btripItem.from between to_date(:year||'-01-01','yyyy-MM-dd') and btripItem.toDate to_date(:year||'-12-31','yyyy-MM-dd');

.....
省略部分赋值的代码..

我看了一下,还真没找到哪里错误!。
谢谢.各位朋友的指点..

[quote]unexpected token[/quote]

错误是,你的HSQL语句中,含有非法字符。

核对下你的语句。

[quote]unexpected token: and near line 1, column 164[/quote]
[color=blue][b]
在第一行的164个字符左右,有非法的字符出现。检查一下。或者仔细看看错误栈,说的是什么非法字符,或者需要什么字符?[/b][/color]

在执行前加一句System.out.println(hql),打印出来看看就知道什么问题了