java - Please provide example for an If statement in hibernate criteria -


how write criteria on if condition using hibernate criteria.

my query needs transformed

select date, product, if(type = 'msrp', amount, 0) price,       if(type != 'msrp', amount, 0) tax productdetail group date, product; 

please provide right usage of if statement in hibernate criteria.

as @jbnizet said,this not supported criteria api. unless using nhibernate

if using nhibernate

  projections.conditional(          restrictions.eqproperty(.............. 

but here possible solutions hibernate.

1)you can use same query using nativesqlquery in such type of situations

2)or using hql.there expression in hql called case when.this might helpful using case statement in hql select


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -