-->
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: Nested Transaction Exception on migrating to Hibernate 4.1.7
PostPosted: Sun Jan 27, 2013 9:43 am 
Newbie

Joined: Mon Jan 14, 2013 6:15 am
Posts: 2
Hi.

I recently migrated an API service of mine from Hibernate 3.6.7 to Hibernate 4.1.7.
Now, I get the following exception very frequently
org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1392)

The exception happens randomly on some APIs but doesn't get reproduced every time. The exception is intermittent.

I made sure to use one single transaction for a function and not creating a nested transaction anywhere in my code. Following is a sample code snippet where the exception happens sometimes :

@Override
public ApiResponse<BaseModel> getLanguages() {
List<BaseModel> result = null;
Integer total;
Transaction trans = null;
try {
trans = dictionaryDao.beginTransaction();
total = dictionaryDao.getLanguagesCount().intValue();
List<LanguageMaster> languageDOList = dictionaryDao.getLanguages();
result = new ArrayList<BaseModel>();
result = format(languageDOList);
trans.commit();
} catch (RuntimeException e) {
if (trans != null)
trans.rollback();
throw e;
}
return getResponse(result);
}

The function dictionaryDao.begintransaction is defined as below :

public Transaction beginTransaction() {
getCurrentSession().setFlushMode(FlushMode.COMMIT);
Transaction t = getCurrentSession().beginTransaction();
return t;
}

The exception occurs while beginning the transaction in dictionaryDao.begintransaction at Transaction t = getCurrentSession().beginTransaction();.

We are using BoneCP as the connection pool provider.

Can someone provide any help on how to get around this random error ?

Thanks,
Rajat


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.