I m trying to call API with input parameter Diagnosticcentreid And getting error as
java.lang.IllegalArgumentException: Unknown parameter name : Diagnosticcentreid
Where is my mistake can anyone help me?
public List<DiagnosticDoctor> getDiagnosticdoctor(int Diagnosticcentreid){
Session session = SessionUtil.getSession();
Query query = session.createSQLQuery("SELECT d.diagnosticcentreid, d.doctorname, d.specializationname, d.tagline, d.clinicname, d.daysname, d.time\n" +
" FROM diagnosticdoctormapping ddm, doctor d where d.diagnosticcentreid = :ddm.Diagnosticcentreid");
query.setInteger("Diagnosticcentreid", Diagnosticcentreid);
List<Object[]> dataList = query.list();
List<DiagnosticDoctor> diagnosticDoctorList =new ArrayList<DiagnosticDoctor>();
for(Object[] obj:dataList){
DiagnosticDoctor dt = new DiagnosticDoctor();
dt.setDiagnosticcentreid(Integer.parseInt(String.valueOf(obj[0])));
dt.setDoctorname(obj[1].toString());
dt.setSpecializationname(obj[2].toString());
dt.setTagline(obj[3].toString());
dt.setClinicname(obj[4].toString());
dt.setDaysname(obj[5].toString());
dt.setTime(obj[6].toString());
diagnosticDoctorList.add(dt);
}
session.close();
return diagnosticDoctorList;
}
This my resource Class:
@Path("/getdoctor/{Diagnosticcentreid}")
@Produces("application/json")
public Response getDiagnosticdoctor(@PathParam("Diagnosticcentreid") int Diagnosticcentreid) {
DiagnosticDoctorMappingDAO dao = new DiagnosticDoctorMappingDAO();
List dtm = dao.getDiagnosticdoctor(Diagnosticcentreid);
String json = new Gson().toJson(dtm);
return Response.ok().entity(json.toString()).build();
}
change your sql to
notice the removal of "ddm."