J'ai modèle avec paramètre d'objet.comment envoyer Liste <model> en ajoutant son paramètre en tant qu'objet
S'il y a 3 candidats différents, il devrait afficher 3 candidats, mais mon résultat est de répéter le dernier candidat 3 fois. Je ne reçois pas les 2 premiers détails du candidat.
public class CandidateFeedbackDisplay implements Serializable{
private Candidate candidate;
private List<Integer> feedbackIds;
//setter and getters
}
public List<CandidateFeedbackDisplay> list(Integer cID, Integer jID, String accepted) throws Exception {
Session session = this.sessionFactory.getCurrentSession();
List<Candidate> candidateList = null;
CandidateFeedbackDisplay feedbackDisplay = new CandidateFeedbackDisplay();
List<CandidateFeedbackDisplay> feedbackDisplayList = new ArrayList();
// List<CandidateFeedbackDisplay> feedbackDisplayListTest = null;
try {
Query query = session.createQuery("from Candidate WHERE phoneNumber IN (select DISTINCT mobileNo from InviteCandidates WHERE c_id= :cID AND j_id= :jID AND status= :accepted)");
query.setInteger("cID", cID);
query.setInteger("jID", jID);
query.setString("accepted", accepted);
candidateList = query.list();
Iterator itr = candidateList.iterator();
while(itr.hasNext()){
Candidate candidate = (Candidate) itr.next();
System.out.println("candidate.getCandidateID() : " + candidate.getCandidateID());
List<CandidateFeedback> candidateFeedback = this.getFeedback(cID, jID, candidate.getCandidateID());
Iterator itr1 = candidateFeedback.iterator();
List<Integer> feedbackid = new ArrayList<Integer>();
while(itr1.hasNext()){
CandidateFeedback Feedback = (CandidateFeedback) itr1.next();
feedbackid.add(Feedback.getFeedbackID());
}
feedbackDisplay.setFeedbackIds(feedbackid);
feedbackDisplay.setCandidate(candidate);
feedbackDisplayList.add(feedbackDisplay);
// feedbackDisplayListTest.add(feedbackDisplay); // null pointer access error
}
}catch (Exception e) {
e.printStackTrace();
this.logger.error("Error while fetching List :" + e);
return null;
}
return feedbackDisplayList;
}
Vous devez d'abord expliquer votre code (mettre un commentaire) et indiquer le code exact où vous avez problème et également supprimer le code inutile – Ravi
merci pour votre réponse rapide – Priya