sql = SELECT count(*) FROM UserRoleInfo b, PersonBasicInfo a,
(SELECT distinct(u.userRoleId) FROM UserRoleAuth u where u.moduleId ='02000000000000') c
WHERE a.personId = b.userSign
and b.kindSign = 1
and userRoleId = c.userRoleId
and b.districtId like '11%' and b.userLevel = 3
getHibernateTemplate().find(sql);用hibernate 执行这条SQL都是出现不能解析的字符,com.ccidit.crsmis.usermanage.po.PersonBasicInfo这没错误啊
错误:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: ( near line 1, column 120 [SELECT count(*) FROM com.ccidit.crsmis.usermanage.po.UserRoleInfo b, com.ccidit.crsmis.usermanage.po.PersonBasicInfo a,(SELECT distinct(u.userRoleId) FROM com.ccidit.crsmis.usermanage.po.UserRoleAuth u where u.moduleId ='02000000000000') c WHERE a.personId = b.userSign and b.kindSign = 1 and userRoleId = c.userRoleId and b.districtId like '11%' and b.userLevel = 3]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 120 [SELECT count(*) FROM com.ccidit.crsmis.usermanage.po.UserRoleInfo b, com.ccidit.crsmis.usermanage.po.PersonBasicInfo a,(SELECT distinct(u.userRoleId) FROM com.ccidit.crsmis.usermanage.po.UserRoleAuth u where u.moduleId ='02000000000000') c WHERE a.personId = b.userSign and b.kindSign = 1 and userRoleId = c.userRoleId and b.districtId like '11%' and b.userLevel = 3]
可是我用plsql执行一点问题都没有:
SELECT count(*) FROM User_Role_Info b, Person_Basic_Info a,
(SELECT distinct(u.user_Role_Id) FROM User_Role_Auth u where u.module_Id ='02000000000000') c
WHERE a.person_Id = b.user_Sign and b.kind_Sign = 1 and b.user_Role_Id = c.user_Role_Id and b.district_Id like '11%' and b.user_Level = 3
(SELECT distinct(u.userRoleId) FROM UserRoleAuth u where u.moduleId ='02000000000000') c
WHERE a.personId = b.userSign
and b.kindSign = 1
and userRoleId = c.userRoleId
and b.districtId like '11%' and b.userLevel = 3
getHibernateTemplate().find(sql);用hibernate 执行这条SQL都是出现不能解析的字符,com.ccidit.crsmis.usermanage.po.PersonBasicInfo这没错误啊
错误:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: ( near line 1, column 120 [SELECT count(*) FROM com.ccidit.crsmis.usermanage.po.UserRoleInfo b, com.ccidit.crsmis.usermanage.po.PersonBasicInfo a,(SELECT distinct(u.userRoleId) FROM com.ccidit.crsmis.usermanage.po.UserRoleAuth u where u.moduleId ='02000000000000') c WHERE a.personId = b.userSign and b.kindSign = 1 and userRoleId = c.userRoleId and b.districtId like '11%' and b.userLevel = 3]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 120 [SELECT count(*) FROM com.ccidit.crsmis.usermanage.po.UserRoleInfo b, com.ccidit.crsmis.usermanage.po.PersonBasicInfo a,(SELECT distinct(u.userRoleId) FROM com.ccidit.crsmis.usermanage.po.UserRoleAuth u where u.moduleId ='02000000000000') c WHERE a.personId = b.userSign and b.kindSign = 1 and userRoleId = c.userRoleId and b.districtId like '11%' and b.userLevel = 3]
可是我用plsql执行一点问题都没有:
SELECT count(*) FROM User_Role_Info b, Person_Basic_Info a,
(SELECT distinct(u.user_Role_Id) FROM User_Role_Auth u where u.module_Id ='02000000000000') c
WHERE a.person_Id = b.user_Sign and b.kind_Sign = 1 and b.user_Role_Id = c.user_Role_Id and b.district_Id like '11%' and b.user_Level = 3
解决方案 »
- 批处理出错 语句拿到数据库里可以执行 操作一条记录可以多了就会报错 报命令未正确结束 在线等啊!!!!!
- 如何高效的学习?谈谈你对日常生活,学习,工作,管理!不要拍砖
- edtFtpj 的ftp上某个文件夹下面所有文件的时间!!
- ectable 的教程资料,哪位有,请奉献,感激!
- 关于getParameterValues()的问题
- 文件下载直接打开后,另存问题!!!!
- 谁人告诉我,怎么做在线音乐连续播放或例子???
- 请问如何能实现服务器端程序调用用户端PC上的dll文件
- 关于JXLS在excel模板文件中能不能遍历对象中的list
- 请各位大虾,提供学习JSP的网站
- EL表达式报错求解!急!
- hibernate 怪异问题 求各位达人,急。。在线等
类似如下的
return getHibernateTemplate.execute(new HibernateCallback() {
public List<String> doInHibernate(Session session)
throws HibernateException, SQLException {
List results = query.list();
return (List<String>)results;
}
}); 参考这里http://blog.csdn.net/gtuu0123/archive/2009/12/05/4946702.aspx
(SELECT distinct(u.userRoleId) FROM UserRoleAuth u where u.moduleId ='02000000000000') c
WHERE a.personId = b.userSign
and b.kindSign = 1
and userRoleId = c.userRoleId
and b.districtId like '11%' and b.userLevel = 3
"and userRoleId = c.userRoleId " userRoleId是哪里的
另外你可以把的where 条件优化一下 把like放到后边。总是觉得你的HQL不够好,你再看看是否可以优化的更好。 如果权限表数据很多势必影响效率。
HQL貌似不能做这样的查询.
x.y.d这样的语句来连接第三张表select count(*) from A a,B b
where b.c.moduleId ='02000000000000'如果说你的B与C没有配置关系,那这样当然是不能使用的.
(SELECT distinct(u.userRoleId) FROM UserRoleAuth u where u.moduleId ='02000000000000') c