您好我正在尝试更新数据库中的多条记录,如果它们通过if语句。我想更新一个列,但是当我这样做时,它也会更新其他列。
表:约会
id |取消|时间| Doctor_id
代码:
public void cancelDoctorsAppoitmentsByDateBetweenTimeInterval(int idDoctor, Date date, Time from, Time to){
from = new java.sql.Time((long) (from.getTime() - 1.14e+6));
List<Appointment> appointments = getDoctorsAppointmentsByDate(idDoctor, date);
for(Appointment appointment : appointments) {
if(appointment.getDate().equals(date) && appointment.getTime().after(from) && appointment.getTime().before(to)
&& !appointment.isCanceled()){
Appointment appointmentToUpdate = currentSession().find(Appointment.class, appointment.getId());
appointmentToUpdate.setCanceled(true);
}
}
}
当我将取消设为真时。数据库更新也列为时间(它比以前更快地设置1小时)。为什么会这样?