gpt4 book ai didi

java - DataException 无法执行查询

转载 作者:行者123 更新时间:2023-12-01 15:42:17 24 4
gpt4 key购买 nike

您好,我在执行以下查询时遇到 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!=?"

请找到 hibernate 代码片段:

qry = hiberSession.createSQLQuery(GET_USERLIST_BY_GROUP1);
qry.setParameter(0, argUsername);
qry.setParameter(1, argUsername);
qry.setParameter(2, argUsername);
lstUsernamebyGroup = qry.list();

请找出我的异常(exception):

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)

最佳答案

我认为你的 SQL 唯一有点不合适的是你使用“!=”表示不等于。官方的不等于 SQL 运算符是“<>”。 Postgres 也支持“!=”,但也许 Hibernate 在这方面遇到了麻烦。

关于java - DataException 无法执行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7858111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com