• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using 'Case when' in Hibernate Criteria API

 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to create a dynamic query using criteria, but i cannot find any way of using the Case When condition?

Can you use the sql 'Case When' condition using criteria?

Thank you,

John
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so. CASE WHEN is Oracle specific, you can have if statements around building your Criteria object, if that works for you, but if you want to use a DBMS specific SQL command, then I suggest using the SQLQuery object instead of the Criteria object.

Mark
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!