-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Position of exists clause in hql-statement
PostPosted: Mon Feb 23, 2009 6:51 pm 
Newbie

Joined: Wed Jul 20, 2005 9:40 am
Posts: 11
Location: Augsburg
After having tried a bit with the following statement i found out that the position of the exists clause seems to be relevant for hibernate:

Code:
   @NamedQuery (
      name=ModuleSubscription.QUERY_FIND_SUBSCRIBERS,
      query=
         "select ms.subscriber from ModuleSubscription as ms where " +
         " ms.subscriber.active = true and " +
         " exists (select 1 from PersonToe as pt where pt.person = ms.subscriber and pt.toe = :toe) and " +         
         "((ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is null and ms.codeNumber.enValue is null) or " +
         " (ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is :kguValue and ms.codeNumber.enValue is null) or " +
         " (ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is :kguValue and ms.codeNumber.enValue is :enValue)) "
   )


produces this stacktrace:

java.lang.NullPointerException
at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
at org.hibernate.hql.ast.tree.FromClause.getFromElement(FromClause.java:107)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:81)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4253)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3968)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)

But this statement works:

Code:
   @NamedQuery (
      name=ModuleSubscription.QUERY_FIND_SUBSCRIBERS,
      query=
         "select ms.subscriber from ModuleSubscription as ms where " +
         " exists (select 1 from PersonToe as pt where pt.person = ms.subscriber and pt.toe = :toe) and " +         
         " ms.subscriber.active = true and " +
         "((ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is null and ms.codeNumber.enValue is null) or " +
         " (ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is :kguValue and ms.codeNumber.enValue is null) or " +
         " (ms.codeNumber.kgValue = :kgValue and ms.codeNumber.kguValue is :kguValue and ms.codeNumber.enValue is :enValue)) "
   )



I tried with jboss 4.2.2 and 4.2.3 (hibernate: 3.2.4.sp1)

So could this be a hibernate bug or am i doing things wrong?
(I didnt find a related jira on my own)
Regards!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.