我正在尝试使用EntityManager删除数据库中的记录。我正在使用EJB JPA。
它产生错误:Object: null is not a known entity type
。
这是我的代码:
public void deleteAppointment(int staffID, int appointmentID) {
try {
StaffApointmentsPK staffApointmentsPK = new StaffApointmentsPK();
staffApointmentsPK.setAppointmentId(appointmentID);
staffApointmentsPK.setStaffId(staffID);
StaffApointments staffApointments = staffApointmentsFacade.find(staffApointmentsPK);
System.out.println("staff app type " + staffApointments);
em.remove(staffApointments);
em.flush();
但是在我之前对下面这个函数的调用中,它非常相似,但它正在工作。我不明白是什么问题,因为我首先使用staffApointmentsFacade
搜索实体。
这是我的另一个功能:
public StaffApointments getPatientAppointmentDetails(int appointmentID, int staffID) {
StaffApointmentsPK staffApointmentsPK = new StaffApointmentsPK();
staffApointmentsPK.setAppointmentId(appointmentID);
staffApointmentsPK.setStaffId(staffID);
StaffApointments staffApointments = staffApointmentsFacade.find(staffApointmentsPK);
return staffApointments;
}
任何帮助将不胜感激。感谢
修改
我分别通过切换int staffID, int appointmentID
解决了这个问题。谢谢你的帮助!
答案 0 :(得分:0)
我通过分别切换int staffID,int appointmentID来解决它。感谢你的帮助@Donovan和@ ma-ve-rick