title: retrieving List<Entity> from List<Object[]> JPA
body: <p>I have an Entity class calle Publication, a method called getAllPublication that return <code>List&lt;Publication&gt;</code> , but my query inside the method has a resultList of type <code>List&lt;Object[]&gt;</code>, how can I retrieve a list of publication entity fromthe <code>List&lt;Object[]&gt;</code>:
  -here the method :</p>
  
  <pre><code>public List&lt;Publication&gt; getAllPublication() {
      List&lt;Object[]&gt; listePublication;
      Query q;
      em.getTransaction().begin();
      q=em.createQuery("SELECT c.titrePublication,
      c.datePublication, c.corps,p.login FROM Publication c  JOIN c.employee p ");
      listePublication = q.getResultList();
      //ArrayList&lt;Publication&gt; results = new ArrayList&lt;Publication&gt;();
      //for (Object[] resultat : listePublication)
      //results.add((Publication) resultat[0]);*/
      em.getTransaction().commit();
      return results;
  }
  </code></pre>
  
  <p>thanks in advance.
  here is the entity class </p>
  
  <pre><code> package entities;
  
  import java.io.Serializable;
  import javax.persistence.*;
  
  @Entity
  @NamedQuery(name="Publication.findAll", query="SELECT p FROM Publication p")
  public class Publication  {
  
  
      @Id
      @Column(name="\"idPublication\"")
      private Integer idPublication;
  
      private String corps;
  
      @Column(name="\"datePublication\"")
      private String datePublication;
  
      @Column(name="\"titrePublication\"")
      private String titrePublication;
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="auteur")
      private Employee employee;
  
      public Publication() {
      }
  
      public Integer getIdPublication() {
          return this.idPublication;
      }
  
      public void setIdPublication(Integer idPublication) {
          this.idPublication = idPublication;
      }
  
      public String getCorps() {
          return this.corps;
      }
  
      public void setCorps(String corps) {
          this.corps = corps;
      }
  
      public String getDatePublication() {
          return this.datePublication;
      }
  
      public void setDatePublication(String datePublication) {
          this.datePublication = datePublication;
      }
  
      public String getTitrePublication() {
          return this.titrePublication;
      }
  
      public Employee getEmployee() {
          return employee;
      }
  
      public void setEmployee(Employee employee) {
          this.employee = employee;
      }
  
      public void setTitrePublication(String titrePublication) {
          this.titrePublication = titrePublication;
      }
  }
  </code></pre>