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.