i am working with stateless session for batch job in my Play Framework 1.2.4 project.
i am inserting and updating rows quite good, but i dont know what to do when an exception occured. Heres my code:
try{
statelesssession.insert(someobject);
}
catch(ConstraintViolationException e) //It happens from time to time dont ask me why..
{
??????transaction.rollback();????? THATS MY CONCERN
}
finally{
transaction.commit();
}
What i need to know is, i am committing data at every 100 inserts. i am wondering, if constraintviolation happens in i.e 56th record and transaction does the rollback, will i lose the other 55 records too?
if yes, what do i have to do in constraintviolationexception? or shall i commit in every 1 record to avoid this?