-->
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: Hibernate with Ingress - Deadlock problem
PostPosted: Wed Apr 13, 2005 2:03 am 
Newbie

Joined: Wed Dec 08, 2004 1:49 am
Posts: 4
Hi,
We are using Hibernate 2.1.7 with Ingress Database and EDBC (edbc.jar) as a jdbc driver for my web application. Things are working fine for single user. If more then one user try to access (getting ) data from same table then I am getting Deadlock exception.

Can anyone please help us.

Hibernate Utility

public class HibernateUtility
{
private static final SessionFactory sessionFactory;
private static final ThreadLocal session = new ThreadLocal();
private static final ThreadLocal transaction = new ThreadLocal();
private static final String HIBERNATE_FACTORY =
"java:/hibernate/HibernateFactory";

static
{
try
{
// Create the SessionFactory
Context ctx = new InitialContext();
sessionFactory = (SessionFactory) ctx
.lookup(HIBERNATE_FACTORY);
}
catch (Throwable ex)
{
throw new ExceptionInInitializerError(ex);
}
}

private static Session currentSession() throws HibernateException
{
synchronized (session)
{
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null)
{
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
}

private static void closeSession() throws HibernateException
{
synchronized (session)
{
Session s = (Session) session.get();
session.set(null);
if (s != null)
{
s.close();
}
s = null;
}
}

private static void beginTransaction() throws HibernateException
{
synchronized (transaction)
{
Transaction tx = (Transaction)transaction.get();
if(tx == null)
{
tx = currentSession().beginTransaction();
transaction.set(tx);
}
}
}

public static void commitTransaction() throws HibernateException
{
synchronized (transaction)
{
Transaction tx = (Transaction)transaction.get();
try
{
if(tx != null &&
!tx.wasCommitted() &&
!tx.wasRolledBack())
{
tx.commit();
}
tx = null;
transaction.set(null);
}
catch(HibernateException ex)
{
rollbackTransaction();
throw ex;
}
}
}

private static void rollbackTransaction() throws HibernateException
{
synchronized (transaction)
{
Transaction tx = (Transaction)transaction.get();
try
{
transaction.set(null);
if(tx != null &&
!tx.wasCommitted() &&
!tx.wasRolledBack())
{
tx.rollback();
}
}
finally
{
closeSession();
}
}
}
}


Exception

Caused by: ca.edbc.util.EdbcEx: Deadlock detected, your single or multi-query transaction has been aborted.
at ca.edbc.jdbc.EdbcObj.readResults(Unknown Source)
at ca.edbc.jdbc.EdbcObj.readResults(Unknown Source)
at ca.edbc.jdbc.EdbcPrep.exec(Unknown Source)
at ca.edbc.jdbc.EdbcPrep.executeQuery(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:314)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
... 76 more


Top
 Profile  
 
 Post subject: Deadlock Error
PostPosted: Wed Oct 26, 2005 6:30 am 
Newbie

Joined: Wed Oct 26, 2005 6:25 am
Posts: 1
Hibernate 2.1.7 with Ingress Database and EDBC (edbc.jar) as a jdbc driver for my web application.

Its working fine for single user. If more then one user try to access data from same table then I am getting Deadlock exception.

I am getting the Error below

ca.edbc.util.EdbcEx: Deadlock detected, your single or multi-query transaction has been aborted

_________________
Need help to resolve deadlock error

ca.edbc.util.EdbcEx: Deadlock detected, your single or multi-query transaction has been aborted


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.