• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Case .. when statements in HQL

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to implement a SQL query (with case when stmt) in HQL.
HQL documentation says that HQL supports the case when statement.
But when i converted the query to HQL, it gives me errors ..

Here is the query:
select prod,
case when length(prod.category) > 0 then prod.category
when length (prod.iTax.icCategoryId) > 0 then
(select pt.portalPcategoryName from Products p join p.iTax ic join ic.pim pim join pim.pT pt where pt.portals.portalId = ortalId and p.productId = prod.productId) end as category
from Products prod where prod.clients.feedId = :feedId and prod.deadUrlLink = :bln1 and prod.active = :bln2

==========================================================
The exception i receieve is :
org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: query
==========================================================

This query works correctly in postgresql.
Can someone point out where I am going wrong.
Thanks a lot.

Harsha
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or does anyone know how to use the CaseFragment stmt (which I am assuming is for Case when stmt) using the criteria API ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic