我尝试使用输入参数Diagnosticcentreid调用API并将错误视为
java.lang.IllegalArgumentException:未知参数名称:Diagnosticcentreid
我的错误可以帮助我吗?
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;
}
这是我的资源类:
@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();
}
答案 0 :(得分:1)
将您的sql更改为
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 = :Diagnosticcentreid");
注意删除&#34; ddm。&#34;