-->
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: batch insert exeption- get the object that causes the error
PostPosted: Tue Sep 26, 2006 9:29 am 
Newbie

Joined: Tue Sep 26, 2006 9:14 am
Posts: 5
I'm creating multiple objects and then i try to insert them into DB by session.flush() and then commit(). If one of those objects causes an error, the commit fails, and as the documentation says, i have to close my seesion.
BUT i dont want to lose all my other objects...
Is there a way to get from session the object that causes constraint violation exception , so that i could merge the rest of the objects into the new session and try to commit them again?

code example:

for(int i=0; i<10; i++){
session.save(person);
}

tx = session.beginTransaction();

try{
tx.commit();
}
catch(HibernateException e){
tx.rollback();
// in here i need to know which person object caused an constraint violation exception so that i can save all the other objects in another session....
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.