-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate error when using SELECT CASE WHEN
PostPosted: Wed Apr 20, 2016 5:30 am 
Newbie

Joined: Wed Apr 20, 2016 5:28 am
Posts: 2
I am trying to run this Named query to return 1 if it finds any record that meets WHERE condition

SELECT CASE WHEN EXISTS (SELECT p FROM Books p WHERE bookNum = :bookNum AND author = :author AND bookID <> :bookID) THEN 1 ELSE NULL END

I used EXISTS to make it fast but I get this error on TOMCAT SERVER START.

org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT CASE WHEN EXISTS (SELECT p FROM com.userclasses.Books p WHERE bookNum = :bookNum AND author = :author AND bookID <> :bookID) THEN 1 ELSE NULL END ] at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54) at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47) at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:549) at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:413) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)

I ran the below to get hibernate version as it says in this link that it was fixed https://hibernate.atlassian.net/browse/HHH-467

System.out.println(org.hibernate.Version.getVersionString());
System.out.println("Hibernate Version: "+ org.hibernate.annotations.common.Version.VERSION);
It tell me this in console

3.6.4.Final
Hibernate Version: 3.2.0.Final


Top
 Profile  
 
 Post subject: Re: Hibernate error when using SELECT CASE WHEN
PostPosted: Wed Apr 20, 2016 12:54 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
This is not possible, check this SO question.


Top
 Profile  
 
 Post subject: Re: Hibernate error when using SELECT CASE WHEN
PostPosted: Thu Apr 21, 2016 4:25 am 
Newbie

Joined: Wed Apr 20, 2016 5:28 am
Posts: 2
That makes me feeling like crying :'(


Top
 Profile  
 
 Post subject: Re: Hibernate error when using SELECT CASE WHEN
PostPosted: Thu Apr 21, 2016 5:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can use a native query for this purpose.


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

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.