posted 8 years ago
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?