File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Case .. when statements in HQL

 
Harsha Pherwani
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • 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
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • 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 ?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic