Hi,
I'm trying to use Hibernate for the first time and naturally, I've a problem :-)
My application is very simple:
- Hibernate v3
- java 1.6
- MySQL 5
Just one table on DB:
Code:
CREATE TABLE `indications_flash` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`definition` tinytext NOT NULL,
PRIMARY KEY(`id`)
)
ENGINE=INNODB;
Programmatically, on java code, I'd like to do a select with a lock (pessimistic method) like that:
Code:
List<IndicationFlash> data = session.createQuery("from IndicationFlash").list();
for (IndicationFlash dd : data)
{
session.lock(dd, LockMode.UPGRADE);
.....
}
Now, I'm running 2 instances of my small application.
- The first instance start immediately and works fine.
- the second instance starts, waits (too much time) on the lock, and throws an org.hibernate.exception.GenericJDBCException: could not lock:....
My question is: how can obtain "immediately" the Exception for my second instance ? In fact, I'd like to have a lock timeout near than 0 (naturally without change any settings of my MySQL's server).
Other way : how can I check if a lock exists ?
My goal is to immediately display a message to the user without waiting the timeout.
Tx & bests regards,
A. HAMEL.