title: Hibernate native query return List Object List
body: <p>I am using an hibernate NQL query which fetches me two columns :</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT object_name, 
         object_name_location 
  FROM   dbo.object_stacks 
  WHERE  object_id IN (SELECT thumb_nail_obj_id 
                       FROM   dbo.uois 
                       WHERE  Upper(NAME) LIKE Upper('%testobj%')) 
  </code></pre>
  
  <p>When I select only one column i.e only object name - everything works fine but with two columns I am getting an error</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
    java.lang.String</p>
  </blockquote>
  
  <p>at run time when I try to display result from the list. I tried using String array in the list as well but it doesn't work. Below are my code snippets which give error : </p>
  
  <p>When I use only List : </p>
  
  <pre><code>List&lt;String&gt; Thumbnailpaths = pathquery.list();
  System.out.println(Thumbnailpaths.get(i).replace("\\", "\\\\"));
  </code></pre>
  
  <p>No error at compile time also nothing if leave it as it is but above line to display gives classcast exception.</p>
  
  <p>When I use List  array : </p>
  
  <pre><code>List&lt;String[]&gt; Thumbnailpaths = pathquery.list();
  
  System.out.println(Thumbnailpaths.get(i)[0].replace("\\", "\\\\"));
  </code></pre>
  
  <p>Here again classcast exception at runtime</p>
  
  <p>Also <code>Criteria.ALIAS_TO_ENTITY_MAP</code> doesn't help at all as it makes logic much more complex. I just need 2 column values from a database table.</p>
  
  <p>Please let me know if there is any solution to fetch multiple column results in NQL and then put in list.</p>
  
  <p>Note : Looks like here generics are not displaying and only List is being written in my code snippet</p>