-->
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: Hibernate Transaction rollback Doesnot work
PostPosted: Tue Feb 22, 2011 12:11 am 
Newbie

Joined: Tue Feb 22, 2011 12:03 am
Posts: 1
Hi,

1. I am working on a project, where it make use of LDAP and mysql for storing user records.In my case, when a user
registers,some details go and sit into mysql and some into LDAP.
2. In this scenario,the save happens first in mysql then into LDAP, but in case there is any exception/error occurred during
saving to LDAP, the entries made into mysql should be rolled back.
3. But in may case I am trying to do that, and it thorws exception saying "org.hibernate.TransactionException: Transaction
not successfully started"
but it seems its trying to save the record into db.

here is the piece of code.

************************************************************************

public void saveorUpdate( Object instance )
{
boolean isFlag=false;
Session session = null;
Clasuser clasUser =null;
Transaction txn = null;

try{

session = sessionFactory.getCurrentSession();
session.saveOrUpdate( instance );
clasUser = (Clasuser)instance;
if(clasUser.getAction().equalsIgnoreCase("Add"))
isFlag = insertUserLDAP(clasUser);
else
isFlag = updateLDAP(clasUser);
//session.flush();
}catch(NamingException runExcp){

session.getTransaction().rollback();
}

}


************************************************************************

Guys, need your expert help to solve my issue.

Thanks,
Abhijit

_________________
Thanks,
Abhijit


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.