title: How to get values of script sql to an object java
body: <p>I have two object Person and Student Mapped with hibernate in my database and another object ObjectPR which brings together the two for showing values of two objects in same view</p>
  <p>and this is my code java for getting list of ObjectPR</p>
  <pre><code>StringBuffer sql = new StreingBuffer();  
    sql.append(&quot;select p.name as name, s.level as level from 
      person p
          join student s on s.pk_seq = p.fk_student ; &quot;);
      
  
      SQLQuery query = getSession().createSQLQuery(sql.toString());
      query.addEntity(ObjectPR.class);
     
      List results = query.list();
  </code></pre>
  <p>and this is my ObjectPR Class</p>
  <pre><code>public class ObjectPR {
  
  private String name;
  private int level;
  
  //getters setters ...
  }
  </code></pre>
  <p>and I got this error</p>
  <pre><code>org.hibernate.MappingException: Unknown entity: model.ObjectPR
  </code></pre>