日期:2014-05-18  浏览次数:20764 次

hibernate查询语句问题!
hibernate查询语句如下:

Query   q   =   sess.createQuery( "from   TUserBean   user,TOrgBean   org     "
+   "where   user.userOrgId=org.orgId   and   org.state= 'A '   "
+   "and   user.state   =   'A '   start   with   org.orgId= ' "+orgId+ " '  
connect   by   prior   org.orgId   =   org.parentOrgId   order   by   user.createDate   desc ");

报错信息:
org.hibernate.hql.ast.QuerySyntaxException:   unexpected   token:   start   near   line   1,   column   161   [from   cn.com.bean.TUserBean   user,cn.com.bean.TOrgBean   org     where   user.userOrgId=org.orgId   and   org.state= 'A '   and   user.state   =   'A '   start   with   org.orgId= '876 '   connect   by   prior   org.orgId   =   org.parentOrgId   order   by   user.createDate   desc]

是hibernate不支持start   with?还是写错了?删掉start   with   org.orgId= ' "+orgId+ " '   connect   by   prior   org.orgId   =   org.parentOrgId就不会报错。

------解决方案--------------------
建议用jdbc搞定吧
------解决方案--------------------
树状查询是oracle原生语法,hql是没有的,需要用原生SQL查询,