title: Hibernate - createNativeQuery with "non-entity class" result
body: <p>I'm new to all this Hibernate/JPA stuff, so i will try to be as clear as possible.</p>
  
  <p>Is there any way in Hibernate to use createNativeQuery to select a single/or multiple fields in a query without using an Entity class as the return object ?</p>
  
  <p>I'm trying to do this without using any XML related stuff.</p>
  
  <pre><code>Query query = getEntityManager().createNativeQuery("select name from contact where id_contact = :idContact", String.class);
  query.setParameter("idContact", 9293L);
  Object string = query.getSingleResult();
  System.out.println(string);
  </code></pre>
  
  <p>Using this i have the Exception : <code>Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.MappingException: Unknown entity: java.lang.String</code></p>
  
  <p>Thanks</p>
  
  <p>Edit :</p>
  
  <p>I also tried :</p>
  
  <pre><code>Query query = getEntityManager().createNativeQuery("select name from contact where id_contact = :idContact");
  query.setParameter("idContact", 9293L);
  List list = query.getResultList();
  if (!list.isEmpty()){ 
      Object string = list.get(0);
      System.out.println(string);
  }
  </code></pre>
  
  <p>With the same Exception : <code>Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;</code></p>
  
  <p>Edit (2) : 
  I'm starting to think it's either a bug in Hibernate or it's impossible to do such things...</p>