I am using the following code to execute while hit the submit button, I am getting the following error and not sure where the mistake was, can anyone gimme a suggest here?
private ModelAndView save(HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
User user = userService.getLoggedInUser(request);
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
String funderName = request.getParameter("funderId");
Long funderId = Long.parseLong(funderName);
String amount = request.getParameter("amount");
Long amountLong = Long.parseLong(amount);
String purpose = request.getParameter("purpose");
Long purLong = Long.parseLong(purpose);
String from = request.getParameter("from");
Date fromDate = formatter.parse(from);
String to = request.getParameter("to");
Date toDate = formatter.parse(to);
FundsDetails fundsDetails = new FundsDetails();
fundsDetails.setIdStaticFunder(funderId);
fundsDetails.setFundsPurposeId(null);
fundsDetails.setFundAmount(amountLong);
fundsDetails.setStartDate(fromDate);
fundsDetails.setEndDate(toDate);
fundsDetails.setLastModifiedBy(user.getId());
funderRepository.createFund(fundsDetails);
FundsProductPurpose fundsProductPurpose = new FundsProductPurpose();
fundsProductPurpose.setIdFundsDetails(fundRepository.getFundsList().get(0).getId());
fundsProductPurpose.setIdStaticLoanPurpose(purLong);
fundsProductPurpose.setLastModifiedBy(user.getId());
funderRepository.createFundProduct(fundsProductPurpose);
List<FundsProductPurpose> fppList = funderRepository.getFundsList();
FundsProductPurpose fpp = fppList.get(0);
//Integer val = fpp.getId();
//System.out.println("*funderRepository.getFundsList().get(0).getId().longValue()*"+val);
FundsDetails fd = fundRepository.getFundsList().get(0);
System.out.println("FundsDetails fd***"+fundRepository.getFundsList().get(0).getFundsPurposeId());
/*fd.setFundsPurposeId(val);
commonRepository.update(fd);*/
return doMapping("result", "Funder details added successfully",
request);
} catch (Exception e) {
e.printStackTrace();
return doMapping("result", "Unable to add funder details", request);
}
}
Error I am getting is,
java.lang.ClassCastException: com.mmf.model.FundsDetails cannot be cast to com.mmf.model.FundsProductPurpose
at com.mmf.controllers.SaveFundsController.save(com.mmf.controllers.SaveFundsController:98)
Aucun commentaire:
Enregistrer un commentaire