[hibernate-dev] Case...When..then... problem

ManiKanta G manikanta.gade at sifycorp.com
Mon Jul 14 03:24:00 EDT 2008


Hi,

I've a query in MySQL which includes CASE.... WHEN... THEN...THEN....END 
type, which i working fine.

select cds.id,
case when cds.source_type = 'c'
then (select cm.company_name from esi_companymaster cm where 
cm.company_code = cds.source_id)
when cds.source_type = 'd'
then (select dm.dealer_name from esi_dealermaster dm where 
dm.dealer_code = cds.source_id) end
as company_dealer_name
from esi_cds_issues_dispensary_details cds

But when I converted the same into HQL, like the below one:

select cds.id,
case when cds.sourceType is 'c'
then (select cm.companyName from CompanyMaster cm where cm.companyCode = 
cds.sourceId)
when cds.sourceType is 'd'
then (select dm.dealerName from DealerMaster dm where dm.dealerCode = 
cds.sourceId) end
as company_dealer_name
from IssuestoDispenceryDetails cds

I m getting NullPointerException (unexpected AST node: query) exception.

Can any one suggest me what am I doing wrong? or is there any work 
around for this.

I need this very urgent. Thanks in advance.


Regards,
ManiKanta G




********** DISCLAIMER **********
Information contained and transmitted by this E-MAIL is proprietary to 
Sify Limited and is intended for use only by the individual or entity to 
which it is addressed, and may contain information that is privileged, 
confidential or exempt from disclosure under applicable law. If this is a 
forwarded message, the content of this E-MAIL may not have been sent with 
the authority of the Company. If you are not the intended recipient, an 
agent of the intended recipient or a  person responsible for delivering the 
information to the named recipient,  you are notified that any use, 
distribution, transmission, printing, copying or dissemination of this 
information in any way or in any manner is strictly prohibited. If you have 
received this communication in error, please delete this mail & notify us 
immediately at admin at sifycorp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20080714/aecda295/attachment.html 


More information about the hibernate-dev mailing list