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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Rollback does not work
PostPosted: Sun Jul 15, 2007 12:21 pm 
Beginner
Beginner

Joined: Sun Nov 19, 2006 6:18 am
Posts: 28
Hi ,
Can some one plz tell me how to rollback in hibernate.I have tried transaction.rollback() on numerous occassions but it does not help. All forums on the internet indicate this as the only way of rolling back but it does not seem to work for me.

Kindly help


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 15, 2007 3:16 pm 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
getTransaction().rollback() does work. There must be something else going on in your particular situation. Perhaps you have auto commit on?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 6:00 am 
Beginner
Beginner

Joined: Sun Nov 19, 2006 6:18 am
Posts: 28
This is the
code snippet i tried

Session session=HibernateUtil.currentSession();
Transaction transaction=session.beginTransaction();
SmHostBean hostBean=new SmHostBean();

//if I print here session.connection().getAutoCommit(),it prints false

hostBean.setId(2);
hostBean.setIpaddress("22");
hostBean.setPort("22");
session.save(hostBean);
hostBean=new SmHostBean();
hostBean.setId(1); //this id already exists in the DB
hostBean.setIpaddress("11");
hostBean.setPort("11");
session.save(hostBean);
try{
transaction.commit();

}catch (Exception e) {
transaction.rollback();
}[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 18, 2007 11:29 am 
Newbie

Joined: Sun Jan 29, 2006 9:27 pm
Posts: 10
I have the same problem. The sad thing is that this once worked very well. I'm trying to understand what is wrong but no luck yet. Check my posts in http://forum.hibernate.org/viewtopic.ph ... highlight= about the same problem.

By the way, my session.connection().getAutoCommit() also prints false.

Best Wishes
Demián.


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