0

Hi I'm getting DataException while executing the following query :

 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!=?"

Please find the piece of hibernate code :

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

Please find my 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)
2
  • You're missing the message from the exception, which will no doubt explain what's wrong... Commented Oct 22, 2011 at 7:46
  • 3
    Is there no nested exception? I'd expect there to be... Commented Oct 22, 2011 at 7:58

1 Answer 1

1

The only thing I see slightly out of place with your SQL is the fact that you use "!=" for not equal. The official not equal SQL operator is "<>". Postgres supports "!=" as well, but maybe Hibernate has trouble with that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.