首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

hibernate查询语句有关问题

2012-01-18 
hibernate查询语句问题!hibernate查询语句如下:Queryqsess.createQuery( fromTUserBeanuser,TOrgBeanorg

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查询,

热点排行