-->
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: Rollback issue with batch insert
PostPosted: Mon Feb 08, 2010 3:16 pm 
Newbie

Joined: Tue Nov 04, 2008 2:22 pm
Posts: 4
Lets say i have 100 rows to insert and the 100th item has an error (eg a value to big for column). When the commit is executed an exception is thrown and rollback is called. However, the first 99 records are still being persisted to the database and not being rolledback.

I am using an oracle database and running in a JBoss 4.0.2 container using an MBean managed SessionFactory and jboss transaction manager

The code looks like this:

Code:
session = sessionFactory.openSession();
tx = session.beginTransaction();
try{
   for (int i = 0; i < 101; i++) {
      ValueObject obj = new ValueObject();
      obj.setValue("TEST");
      session.save(obj);
   }
   tx.commit();
} catch(HibernateException he){
   tx.rollback();
} finally {
   session.close();
}


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.