-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: lock timeout duration / question from an hibernate beginner
PostPosted: Wed May 06, 2009 12:29 pm 
Newbie

Joined: Wed May 06, 2009 11:19 am
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.