-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL Help
PostPosted: Tue Jul 19, 2005 9:35 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.3

Name and version of the database you are using:
PostgreSQL8.0

Hi

I have a SQL query with case when

i.e).
"select field_1,field_2,field_3,field_4,sum(case when transaction_type = 'Purchase Return' then -1*actual_quantity when transaction_type = 'Sale Order' then -1*actual_quantity else actual_quantity end) from inventory_transaction_stock_view group by field_1,field_2,field_3,field_4"

I want to write an hql query for the above sql can anyone help me on this.

I can write an hql without case and it works properly
i.e)
"select info.fieldone,info.fieldtwo,info.fieldthree,info.fieldfour,sum(info.actualquantity) from InventoryTransStockViewInfo info group by info.fieldone,info.fieldtwo,info.fieldthree,info.fieldfour"

How do i use case when in the above HQL?

I have also tried with Criteria couldn't find a solutionf for "case when" Query

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 2:01 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
look at the answer of
http://forum.hibernate.org/viewtopic.ph ... t=subquery


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 6:20 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
HI

I tried the below Query but couldnt make the HQL work

"select info.fieldone,info.fieldtwo,info.fieldthree,info.fieldfour,sum(case when info.transactionType in ('Purchase Return','Sale Order') then -1*info.actualquantity else info.actualquantity end) from InventoryTransStockViewInfo info group by info.fieldone,info.fieldtwo,info.fieldthree,info.fieldfour"

Thanks in Advance

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.