title: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
body: <p>why java.lang.ClassCastException is triggered in my program ?</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
    com.App.Equip]</p>
  </blockquote>
  
  <p>The query returns the list of checklists that are answered (found in the CheckLists calsse) and not yet answered by Equip object</p>
  
  <p>-Here is the code:</p>
  
  <pre><code>import org.json.simple.*;
  
      @SuppressWarnings("unchecked")
  
  public JSONObject ListCheckListsNonETRepondu( long idEqp, long idmiss){
  
         Query query = manager.createNativeQuery("SELECT"
          + " checksl.id_check_lists as IdCheckLists,"
          + " checksl.titre_check as NomCheckLists,"
          + " checksl.recommendation as Recommendation, "
          + " resp.id_responsescheck as IdResponse, "
          + " resp.conformite as Conformite, "
          + " resp.date_response as DateResponse, "
          + " resp.missions_id as IdMission "
          + " FROM equipements eq "
          + " LEFT JOIN check_lists checksl"
          + " ON eq.id_equipements= checksl.equipements_id "
          + " LEFT JOIN responses_check_lists resp "
          + " ON checksl.id_check_lists = resp.check_lists_id "
          + " AND resp.missions_id ="+idmiss+""
          + " AND eq.id_equipements ="+idEqp
          + " ORDER BY checksl.id_check_lists"
           );
  
     List&lt;Equip&gt; res = query.getResultList();
  
     JSONObject obj = new JSONObject();
  
     for( Equip eq: res) //--The problem is here --
     {
         for(CheckLists checks : eq.getChecks())
         {
                obj.put("idCheckLists", checks.getIdCheckLists());
                obj.put("NomCheckLists", checks.getTitreCheck());
                obj.put("Recommendation", checks.getRecommendation());
  
                for(ResponsesCheckLists resp :checks.getResponsesChecks())
                 {
                    obj.put("IdResponse",resp.getIdResponsesCHeck());
                    obj.put("DateResponse",resp.getDateResponse());
                    obj.put("Conformite",resp.isConformite());
                    obj.put("IdMission",resp.getRespmission().getIdMission());
                 }
         }
  
     }
     return (JSONObject)obj; 
     }
  </code></pre>
  
  <p>-My java classes:</p>
  
  <pre><code>@Entity
  public class CheckLists implements Serializable{
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="idCheckLists")
      private long idCheckLists;
  
      @Column(name="titreCheck")
      private String titreCheck;
  
      @Column(name="recommendation")
      private String recommendation;
  
      @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      @JoinColumn(name="equipements_id")
      @JsonBackReference
      private Equipements equipements;
  
      @OneToMany(mappedBy="CheckLts", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
      //@Fetch(value = FetchMode.SUBSELECT)
      private Set&lt;ResponsesCheckLists&gt; ResponsesChecks;
   ..
  }
  
  //
  @Entity
  public class ResponsesCheckLists implements Serializable{
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="idResponsesCHeck")
      private long idResponsesCHeck;
  
      @Column(name="conformite")
      private boolean conformite;
  
      @Column(name="dateResponse")
      private String dateResponse;
  
      @ManyToOne
      @JoinColumn(name="missionsId")
      private Missions Respmission;
  
      @ManyToOne
      @JoinColumn(name="checkLists_Id")
      private CheckLists CheckLts;
  
  ....
  }
  
  //
  @Entity
  public class Equip implements Serializable{
  
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="idEquipements")
      private long idEquipements;
  
      @Column(name="nomEq")
      private String nomEq;
  
      @Column(name="dateAjoutEq")
      private String dateAjoutEq;
  
      @Column(name="dateModificationEq")
      private String dateModificationEq;
  
      @OneToMany(mappedBy="equipements", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
      //@Fetch(value = FetchMode.SUBSELECT)
      @JsonManagedReference
      private Set&lt;CheckLists&gt; checks;
  
      @ManyToOne
      @JoinColumn(name="actifs_id")
      private Actifs actifsEquipements;
  }
  </code></pre>
  
  <p>I want to format the result of my SQl query in Json format. 
  Here is what the SQL query returns <code>query.getResultList()</code>:</p>
  
  <pre><code>[
     [
      1,
     "2.1 Create Separate Partition ",
     "Description.... ",
      1,
      false,
     "25/05/2017",
      15
    ],
    [
      2,
     "2.2 Set nodev option ",
    " Description:.... ",
      1,
      false,
     "25/05/2017",
     15
     ]
  ......
  ]
  </code></pre>
  
  <p>could anyone mind giving some advice for me?</p>
  
  <p>Thanks a lot!!!</p>