读书人

hibernate查询语句有关问题

发布时间: 2012-01-18 00:23:26 作者: rapoo

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

读书人网 >Java Web开发

热点推荐