Query conversion - Sql to Hql

前端 未结 1 1215
离开以前
离开以前 2021-01-29 04:49

I have this query and I need to convert it in hql but I am little confused, don\'t know how to write condition presented in \'where\' clause in hql.

SELECT
    m         


        
相关标签:
1条回答
  • 2021-01-29 04:58

    Please find below the HQL query: Assuming that p_message & p_config are domain object names & others are attributes mapping to column.

      String hqlQuery =" SELECT message  FROM     p_message  pm WHERE pm.message_id in (SELECT a.scene FROM p_config a INNER JOIN  p_rec_type b  ON a.email_id=b.email_id AND rec_type =:rectype          WHERE a.email_type=:emailTYpe)"; 
        query = session.createQuery(hqlQuery);
        query.setParameter("rectype", 2);
        query.setParameter("emailTYpe", 1);
    
    0 讨论(0)
提交回复
热议问题