【发布时间】:2020-04-11 23:45:47
【问题描述】:
try {
final CHEMRFacilityMedicalEquipment medicalequ = m_chemrFacilityMedicalEquipmentManagementBO
.findCHEMRFacilityMedicalEquipmentById(id);
final CHEMRFacilityMedicalEquipment updateMed = new CHEMRFacilityMedicalEquipment();
if (medicalequ.getMetaStatus() == true) {
updateMed.setId(medicalequ.getId());
updateMed.setMetaStatus(false);
m_chemrFacilityMedicalEquipmentManagementBO
.updateCHEMRFacilityMedicalEquipment(updateMed);
return true;
}
return false;
}
以上是我在 DaOImpl 中调用我的方法的方式
try {
m_sessionFactory.getCurrentSession().update(instance);
} catch (final DataAccessException _e) {
M_LOG.debug("Update object failed:" + _e.toString());
throw new CHEMRDAOException(_e.toString());
} catch (final Exception _e) {
M_LOG.debug("Update object failed:" + _e.toString());
throw new CHEMRDAOException(_e.toString());
}
}
DAO 实现
我正在尝试更新我的对象并通过更新方法将其发送到更新表中的数据。 当我调用更新方法时,它返回“具有相同标识符值的不同对象已与会话相关联”没有得到究竟是什么问题。
【问题讨论】:
-
请提供完整的堆栈跟踪。您尝试更新
updateMed.setId看起来也很可疑。你不应该这样做。