ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giovanni Cuccu - CUP2000 <giovanni.cu...@cup2000.it>
Subject Re: Autocommit not properly handled in Ibatis.
Date Fri, 19 Jan 2007 11:44:47 GMT
In your code the message for the exception is the same so did you check 
what is causing the exception?
If you get an exception while calling endTransaction() (and after 
getting a previous exception) meaning that ibatis cannot rollback there 
is a chance that you are hitting the default behaviour of the oracle 
jdbc driver i.e. commit while exiting the progam.
Giovanni
P.S. I think if you can post a simple complete test case (with objects , 
sql for creating the test table, etc) the cause of the problem should 
emerge quickly.

> Hi Clinton,
> 
> Thanks for replying early.
> 
> Following is the saveAllRecords which save the list passed.
> List contain the BasicDTO which is serialisable.
> 
> 
> Suppose I have two DTO in list. First DTO is saved successfully and if I
> get exception while saving second DTO , the First DTO which is saved
> earlier should get roll backed. But this is not happening ibatis is
> saving first DTO.i have set auto commit to false. What change I should
> make in order to properly roll back the transaction.
> 
> 
> 	public void saveAllRecords( String id, List recordList )
> 	{
> 		try
> 		{
> 		getSession().startTransaction();
> 			if (!recordList.isEmpty())
> 			{
> 				for (int i = 0; i < recordList.size();
> i++)
> 
> 				{
>   	                     BasicDTO basicDTO = (BasicDTO)
> recordList.get(i);
> 				   getSession().insert(id +"_INSERT",
> basicDTO);
> 				}
> 				
> 			}
>  		getSession().commitTransaction();
> 			
> 		}
> 		catch (SQLException e)
> 		{
> 			throw new RuntimeException("Error while
> Excecuting Batch" 				+ e);
> 		}
> 		finally
> 		{
> 			try
> 			{
> 			   getSession().endTransaction();
> 			}
> 			catch (SQLException e)
> 			{
> 				throw new RuntimeException("Error while
> Excecuting 				Batch" + e);
> 				
> 			}
> 		}
> 		
> 	}
> 
> 
> 
> 
> 
> 
> 
> Regards
>  yuvraj 
> 
> 

>>
>> Yuvraj Shinde * Senior Software Engineer -  Zainet*  SunGard *
> Offshore
>> Services *
>>  Pride Portal,CTS No 103A/5A/1A/1B Bhamburda,Senapati Bapat Road,
>> shivajinagar,Pune 411016
>>  Tel Direct +91 20 66248045 * Main +91 20 66248000 * Fax +91 20
> 25606222
>>  yuvraj.shinde@sos.sungard.com * www.sungard.com
>>
>>
>>
>>
>> Success is never ending and failure is never final.
>>
>>
> 
> 
> 
> 


-- 
Giovanni Cuccu
CUP 2000 Spa
Via del Borgo di S. Pietro, 90/c - 40126 Bologna
e-mail: giovanni.cuccu _at_ cup2000.it


Mime
View raw message