title: Convert SQL query to HQL or map result to hibernate entity
body: <p>I have below SQL query   </p>
  
  <pre><code>select column1 ,column2 ,column3 ,column4 ,column5 ,column6 from (
  select ROW_NUMBER() OVER (PARTITION BY column2 ORDER BY null desc) rn,column1,  
  column2 ,column3 ,column4 ,column5 ,column6
  from TBLCUSTOMERSUBMODULERELATION where column1 = 'somevalue' AND column3 ='somevalue')
  where rn=1;  
  </code></pre>
  
  <p>i want to convert this query to HQL.<br>
  In my code <code>column1,column2,column3</code> is <code>EmbeddedId</code><br>
  I have tried to convert or mapped directly this result in my class object using below code  </p>
  
  <pre><code>session = sessionFactory.openSession();
  SQLQuery sqlQuery = session.createSQLQuery(qry);
  sqlQuery.addEntity(CustomerSubModuleRelationBean.class);
  </code></pre>
  
  <p>but it gives error like <code>Caused by: java.sql.SQLException: Invalid column name</code>  </p>
  
  <p>Is anyone have idea how to use convert this native SQL to HQL or map my result directly to entity class in Hibernate. </p>