• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Query

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Need to create a little more difficult query to my database with hibernate.
The sql statement looks like this:

select customerID,(case when col1=:searchCriteria then amount1 else 0 end + case when :searchCriteria='B' then amount2 else 0 end) from testTable where (:searchCriteria='A' or :searchCriteria='B')

In my Dao class I have tried to perform this query in this way.

Query query = (Query) session.createQuery(sqlStatement)
.setParameter("searchCriteria",searchCriteria);

Is this the right way to do this?

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened when you tried it?

Testing it out is almost always going to be quicker than a forum post...
reply
    Bookmark Topic Watch Topic
  • New Topic