title: JPQL Constructor Expression - org.hibernate.hql.ast.QuerySyntaxException:Table is not mapped
body: <p>My original problem was <a href="https://stackoverflow.com/questions/12172614/hql-join-without-foreign-key-reference">https://stackoverflow.com/questions/12172614/hql-join-without-foreign-key-reference</a>
  but couldn't find any solution for this, hence moved forward with native query using JPA. createNativeQuery of entityManager returns Query object which in turn returns <code>List&lt;Object[]&gt;</code>. I don't want to deal with indexes while iterating the list because it's error prone in nature.Therefore i looked at some other solution for it and found JPQL's Constructor expressions as one of the solution.</p>
  
  <p>Table structure is</p>
  
  <pre><code>Schema1 -TableA
  
   - NameColumn
   - PhoneColumn
  </code></pre>
  
  <p>Corresponding Java class is</p>
  
  <pre><code>    public class PersonSearch implements Serializable {
  
      public PersonSearch (String NameColumn, String PhoneColumn) {
          this.name = NameColumn;
          this.phone = PhoneColumn;
      }
  
      private String name;
  
      private String phone;
  
      public String getName() {
      return name;
      }
  
      public void setName(String name) {
      this.name = name;
      }
  
      public String getPhone() {
      return phone;
      }
  
      public void setPhone(String phone) {
      this.phone = phone;
      }
      }
  </code></pre>
  
  <p>Query is</p>
  
  <pre><code> Select NEW com.xyz.PersonSearch(ms.NameColumn, ms.PhoneColumn) From Schema1.TableA ms Where ms.PhoneColumn='9134409930'
  </code></pre>
  
  <p>while running this query using entityManager API</p>
  
  <pre><code>entityManager.createQuery(queryString, PersonSearch.class);
  </code></pre>
  
  <p>getting below error.</p>
  
  <pre><code>Caused by: org.hibernate.hql.ast.QuerySyntaxException: Schema1.TableA is not mapped   [Select NEW com.xyz.PersonSearch(ms.NameColumn, ms.PhoneColumn) From Schema1.TableA ms Where ms.PHONE='9134409930']
  </code></pre>
  
  <p>What's wrong with my code? Any idea ?</p>