-->
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.  [ 2 posts ] 
Author Message
 Post subject: deadlock problem
PostPosted: Tue Jul 26, 2005 10:38 pm 
Newbie

Joined: Tue Jul 26, 2005 10:25 pm
Posts: 1
Hi there,

I am running into an oracle deadlock problem in developing an application with Hibernate 3.0 and WSAD 5.0 (integrated Edition).

I have a class mapped to a table: A->a, and a's primary key is another table, let's say d, foreign key.
So A and D classes are defined as below:
Code:
class A
{
   Long key;  // map to primary key
   // more attributes defined
   Map ds;    // holds class D instances
}

class D
{
   String type; // not unique but unique in the rows having the same foreign keys
   String att1;
   String att2;
   Long key;    // foreign key from class A
}

Class A metadata file has the following mapping:
Code:
<class name="A"
      table="a"
      lazy="true">

   <id name="key"
      type="long"
      column="key"
      unsaved-value="null">
      <generator class="assigned"/>
   </id>
   
   <property ...></property>
   
   <map      name="ds"
            lazy="true"
            table="d"
            cascade="delete">

            <key column="key" not-null="true" />
            <index column="type" type="string"/>
            <composite-element class="D">
               <property name="att1" column="col1" type="string"/>
               <property name="att2" column="col2" type="string"/>
            </composite-element>   
   </map>
</class>


The following is pseudo code of a transaction:
Code:
public void process(Long key)
{
  Session session = sessionFactory.openSession();
  Transact tx = session.beginTransaction();
  try
  {
   A aa = session.get(A.class, aKey);
   if(aa != null)
   {
      // process business logic
      session.delete(aa);
      tx.commitTransaction();
   }
  }
  catch(HibernateException he)
  {
   tx.rollbackTransaction();
   // may be rethrow as my own exceptions
  }
  finally
  {
   session.close();
  }
}

Then I ran 200 threads, each of them had a unique key (I guarrantee that) passed to the process method, but I got oracle deadlock problem. I use default settings of transaction isolation level for both hibernate and oracle. I just don't under stand why I got deadlock problem.

Anybody can help me with that problem?

Thanks a lot in advance,

Jane


Top
 Profile  
 
 Post subject: I got the same problem
PostPosted: Fri Mar 03, 2006 12:04 pm 
Newbie

Joined: Fri Mar 03, 2006 11:37 am
Posts: 3
Hi,

Ive got the same problem. and i know that the problem can be solved by creating indexes on the foreign keys. But, I dont know how to get hibernate to generate these indexes for me.

Did u find an solution? If not here some further description of the problem:

u can reproduce the behavior using sqlplus. u need two instances concurrently deleting different records:

Code:
session 1:
delete from d where key = 4711;
session 2:
delete from d where key = 4712;
session 1:
delete from a where key = 4711;
session 2:
delete from a where key = 4712;
session 1:
deadlock!!


there is a website discussing that:
http://www.akadia.com/services/ora_lock ... guide.html
especially the section on Referential Integrity Locks is interesting.

I dont have a solution to that. I have this problem with ejb 3.0 on jboss 4.0.4, but I would be interested in anything regarding this topic.

Any help is appreciated. Regards, Milan Wölke


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.