-->
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.  [ 3 posts ] 
Author Message
 Post subject: LockMode.UPGRADE within a stateless session bean
PostPosted: Thu Feb 03, 2005 1:44 pm 
Newbie

Joined: Mon Mar 08, 2004 2:24 pm
Posts: 13
Location: Tampa, FL, USA
I'm trying to obtain a lock on several rows within a session bean. The goal is a resulting "SELECT... FOR UPDATE". The call to list() never returns. No exceptions, no errors. Seems like it's waiting for another lock to be release, but there are no other processes accessing these rows. In fact, while the code is blocked, I've copied the generated SQL (which looks correct) and successfully executed it manually (via TOAD).

The code follows:

Code:
           
       try
       {
            Session session = ThreadLocalSession.currentSession(ThreadLocalSession.HIB_SESS_ORACLE);

            Query q = session.createQuery(
                    "from CaseEmailRequest req where req.item is null");
            q.setLockMode("req", LockMode.UPGRADE);
            List requests = q.list();
       }
       catch (Exception e)
       {
            ... // log exception
       }
       finally
       {
            ... // close session
       }



The method's transaction level was orignally set to "Required". Most of the examples of using LockMode.UPGRADE showed explicit hibernate transactions, so I tried setting the method's tranaction to "NotSupported" and added code to get a transaction from the session, but it still didn't work.

Using:
Hibernate 2.1.4
JBoss 3.2.4
Oracle 9i

Generated SQL:

Code:
       select  caseemailr0_.EMAILREQID as EMAILREQID, 
                 caseemailr0_.DOCKET_NO as DOCKET_NO ,
                 caseemailr0_.PARTY as PARTY,
                 caseemailr0_.EMAIL_TYPE_CODE as EMAIL_TY4_,
                 caseemailr0_.EMAIL_ITEM_ID as EMAIL_I11_
       from   A_CASE_EMAIL_REQ caseemailr0_
       where (caseemailr0_.EMAIL_ITEM_ID is null )
       for update


Anyone have any ideas?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 2:02 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
I've copied the generated SQL (which looks correct) and successfully executed it manually (via TOAD).


when did you do that?
- on a breackpoint after .list
- or at the end of the method (after calling session.close)
?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 2:35 pm 
Newbie

Joined: Mon Mar 08, 2004 2:24 pm
Posts: 13
Location: Tampa, FL, USA
I understand where you're going... the manual execution couldn't have casued the contention. The reason is that before I even attempted the TOAD query, I had run the hibernate query several times -- and sat for up to 3-4 minutes each time -- before finally killing the process. I even restarted the JBoss instance each time to make sure nothing was hanging around.

Running the SQL in TOAD was just a way for me to verify whether something else already had a lock on the rows. I figured if the TOAD query also blocked, then something did already have a lock. But the TOAD query did not block, leading me to believe there's something else going on.


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

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.