Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Query

 
Håkan Axheim
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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?

 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic