I have method which returns List of objects, I m facing a problem while fetching a data from list, I m getting null pointer exception when i am trying to fetch the data.
method which returns List:
public List <EstimationResivion> getEstimationRevision(double rev_id){
List<EstimationDetailRevision> estDetail=estDetailRev(rev_id);
List<EstimationPanelRev> estPanelrev=estPanelRev(rev_id);
List<EstimationPannelDetailRevision> estimationpaneldetailrev=estPanelDetailRev(rev_id);
List<EstimationResivion> estRev=estRevision(rev_id);
EstimationResivion ed= new EstimationResivion();
ed.setEstimationdetailRev(estDetail);
ed.setEstimationpanelRev(estPanelrev);
ed.setEstimationpaneldetailRev(estimationpaneldetailrev);
System.out.println("Size before: "+estRev.size());
estRev.add(ed);
return estRev;
}
estDetailRev
code:
private List<EstimationDetailRevision> estDetailRev(double d){
return getJdbcTemplate().query("SELECT * FROM estimation_detail_rev WHERE rev_id=?", new Object[] {d }, new EstimationDetailRevRowMapper());
}
estRevision
code
private List<EstimationResivion> estRevision(double d){
return getJdbcTemplate().query("SELECT * FROM estimation WHERE est_revision=?", new Object[] {d }, new EstimationRevRowMapper());
}
estRevision
will return list of List<EstimationResivion>
which i am storing in estRev
.
code from where i am calling getEstimationRevision
and trying to fetch data from list
public void getRevision(){
double d=0;
List<EstimationResivion> est=estimationdao.getEstimationRevision(d);
for(EstimationResivion er:est){
System.out.println(er.getEstContactPerson());
System.out.println(er.getEstCustomer());
System.out.println(er.getRevId());
// epd=er.getEstimationpaneldetailRev();
List<EstimationDetailRevision> edr=er.getEstimationdetailRev();
for(EstimationDetailRevision estimaitonDetail:edr){
estimaitonDetail.getCompCategory();
estimaitonDetail.getCompMake();
}
}
I am getting null value when i call er.getEstimationdetailRev();
if i specify the index i am able to getdata something like this:
List<EstimationDetailRevision> edr=est.get(64).getEstimationdetailRev();
My question is how can i fetch data without specifying index ?