下面的代码静默无法更新数据库。这里没有要报告的错误消息。好像行“sessionFactory.getCurrentSession().saveOrUpdate(sn);” (朝向片段的底部)被忽略。我究竟做错了什么?
public String getSerialNumber(String id) {
log.debug("--------------------------------------------------------------------------------------------Looking for Serial number counter named: " + id);
SerialNumber sn = (SerialNumber) sessionFactory.getCurrentSession().get(SerialNumber.class, id);
if (sn == null) {
//TODO Throw an error (maybe). The code below creates a new Serial number counter
log.debug("NO Serial Number for: " + id + " was found.");
sn = new SerialNumber();
sn.setSerialNumberId(id);
sn.setName("Unspecified");
sn.setValue(1);
log.debug("-----------------------------------------" + sn.toString());
sessionFactory.getCurrentSession().save(sn);
log.debug("--------------------------------------------------------------------------------------------Right after SAVE call. This is id --> " + id);
return "1";
}
sn.setValue(sn.getValue()+1);
log.debug("--update---------------------------------" + sn.toString());
log.debug("--update---------------------------------" + sn.getValue());
sessionFactory.getCurrentSession().saveOrUpdate(sn);
log.debug("--update---------------------------------" + sn.getValue());
log.debug("--update------------------------------------------------------------------------------------Right after SAVE call. This is id --> " + id);
return sn.getValue().toString();
}