By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

convert sql into hql : I have written the code whch includes sql queries but i neeed

P: 1
I have written the code whch includes sql queries but i neeed to convert into hql how should i do....

the sql query is :

Expand|Select|Wrap|Line Numbers
  1. String sqlListSurveys= "select distinct s.surveyAutoID, s.surveyTitle, date(s.modifiedOn) modifiedOn, s.createdOn, "
  2.                 + "( CASE s.surveyState WHEN '0' THEN 'Created' WHEN '1' THEN 'Published' "
  3.                 + " ELSE 'UnPublished' END ) surveyState, s.createdby createdby, (select ifnull(max(respondentID),0) FROM response, survey sur where surveyID = sur.surveyAutoID and sur.surveyAutoID=s.surveyAutoID) respondentID "
  4.                 + " from survey s left outer join  response r  on r.surveyID = s.surveyAutoID "
  5.                 + " where createdby = "+userId+" and surveyState != '"+SGSConstants.DELETE_STATE+"' order by createdOn DESC";
  6.  
  7.  
  8.          logger.info(sqlListSurveys);
  9.  
  10.          Query queryListSurveys  = sessionFactory.getCurrentSession().createSQLQuery(sqlListSurveys).setParameter("surveyList",result);
  11.          queryListSurveys .setResultTransformer(Transformers.aliasToBean(Survey.class));
  12.          result = queryListSurveys .list();
  13.          map.put("surveyList", result);
Dec 10 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.