您好我在执行以下查询时遇到了DataException:
GET_USERLIST_BY_GROUP1 = " SELECT usr.user_id,
usr.login_name
FROM user_info usr
WHERE usr.user_id IN
(SELECT g.user_id
FROM group_privilege_details g
WHERE g.group_id IN
(SELECT gp.group_id
FROM group_privilege_details gp,
user_info u
WHERE u.user_id=gp.user_id
AND u.login_name=?)
GROUP BY g.user_id HAVING count(g.group_id) =
(SELECT count(g.group_id)
FROM group_privilege_details gr,
user_info us
WHERE us.user_id=gr.user_id
AND us.login_name=?))
AND usr.login_name!=?"
请找到一块休眠代码:
qry = hiberSession.createSQLQuery(GET_USERLIST_BY_GROUP1);
qry.setParameter(0, argUsername);
qry.setParameter(1, argUsername);
qry.setParameter(2, argUsername);
lstUsernamebyGroup = qry.list();
请找我的例外:
2011-10-22 12:42:55,352 INFO [STDOUT] (http-10.128.15.228-8080-5) org.hibernate.exception.DataException: could not execute query
2011-10-22 12:42:55,352 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
2011-10-22 12:42:55,352 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
2011-10-22 12:42:55,353 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.loader.Loader.doList(Loader.java:2223)
2011-10-22 12:42:55,353 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
2011-10-22 12:42:55,353 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.loader.Loader.list(Loader.java:2099)
2011-10-22 12:42:55,354 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
2011-10-22 12:42:55,354 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
2011-10-22 12:42:55,354 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
2011-10-22 12:42:55,355 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
2011-10-22 12:42:55,355 INFO [STDOUT] (http-10.128.15.228-8080-5) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
答案 0 :(得分:1)
我唯一看到与你的SQL略显不同的是你使用“!=”不相等的事实。官方不等于SQL的运算符是“<>”。 Postgres也支持“!=”,但也许Hibernate有问题。