@SuppressWarnings("unchecked")
//@Override
public SerialNumber getCounter(String id) {
Session cs = sessionFactory.getCurrentSession();
SerialNumber sn = (SerialNumber) cs.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(0);
}
sn.setValue(sn.getValue()+1);
cs.saveOrUpdate(sn);
cs.close();
return sn;
}
This line is being ignored and saves nothing to the database (MySQL):
cs.saveOrUpdate(sn);
Any ideas as to why? I haven’t a clue.
I am by no means Java guru but even the Java guru here cannot figure it out. Any help will be appreciated.
Thanks.
It is possible that the updates are being deferred for the session. Try:
If this is your problem, you can set this to AUTO in your properties: