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 ENDI 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-467System.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