I have multiple machines running a service that is updating and reading values from a database using Hibernate.
Whenever I need to update a DB value in my service, I use an upgrade nowait lock, and if I can’t get the lock, I just retry later.
void lock(Job job) {
sessionFactory.session.lock(job, LockMode.UPGRADE_NOWAIT);
}
There is one place in my service where I must update the DB value there, and I cannot retry. I figured I’d just use a normal upgrade lock in those spots, and it can just wait however long it needs to update the value.
void waitForLock(Job job) {
sessionFactory.session.lock(job, LockMode.UPGRADE);
}
But now I see this error pop up sometimes…
org.hibernate.dialect.HSQLDialect - HSQLDB supports only READ_UNCOMMITTED isolation
Is there a way to guarantee that this value will be updated first time using Hibernate?
You are using an old version of HSQLDB which does not support transaction isolation. Use the latest version (2.2.8 or later) which does.