You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Yuvraj Shinde <Yu...@sos.sungard.com> on 2007/01/19 06:50:47 UTC

Autocommit not properly handled in Ibatis.

Hi all,

 

   I want to know how to handle auto commit in ibatis.if I am saving two
records and if I get an exception while saving second record the first
record saved should be rolled back.

  But ibatis is saving the first record. How I should handle this even
though the auto commit property is explicitly set to false.

 

   Even though AutoCommit value is set to false. Rollback of Transaction
is not working.

   I found one Issue in GeneralStatement.java.

   On line 52  request.getSession().setCommitRequired(true);  

 

   Here Auto commit is hard coded it should be parameterized so that it
will take value from "Auto commit" property of  SqlMapConfig.xml.

   Please correct me if I am wrong.please send me a solution.

 

Regards

Yuvrajs

 

 

 

 

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.

 


Re: Autocommit not properly handled in Ibatis.

Posted by chialda <va...@gmail.com>.
i think your problem is that you're trying to make a transaction inside
another transaction. The inside transaction is commited because of a good
sql, but the outside one, is ended without commit. Be aware of that.





Yuvraj Shinde wrote:
> 
> Hi all,
> 
>  
> 
>    I want to know how to handle auto commit in ibatis.if I am saving two
> records and if I get an exception while saving second record the first
> record saved should be rolled back.
> 
>   But ibatis is saving the first record. How I should handle this even
> though the auto commit property is explicitly set to false.
> 
>  
> 
>    Even though AutoCommit value is set to false. Rollback of Transaction
> is not working.
> 
>    I found one Issue in GeneralStatement.java.
> 
>    On line 52  request.getSession().setCommitRequired(true);  
> 
>  
> 
>    Here Auto commit is hard coded it should be parameterized so that it
> will take value from "Auto commit" property of  SqlMapConfig.xml.
> 
>    Please correct me if I am wrong.please send me a solution.
> 
>  
> 
> Regards
> 
> Yuvrajs
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 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.
> 
>  
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Autocommit-not-properly-handled-in-Ibatis.-tf3038413.html#a8766614
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Autocommit not properly handled in Ibatis.

Posted by Cornel Antohi <ca...@kepler-rominfo.com>.
Hi Clinton,

1) What do you mean by "iBATIS never uses AutoCommit"? Here is what I found in: 
com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction --> private void init() throws SQLException, TransactionException

// AutoCommit
if (connection.getAutoCommit()) {
    connection.setAutoCommit(false);
}


Thank you,
Cornel

----- Original Message ----- 
From: "Clinton Begin" <cl...@gmail.com>
To: <us...@ibatis.apache.org>
Sent: Friday, January 19, 2007 8:52 AM
Subject: Re: Autocommit not properly handled in Ibatis.


A few things:

1) iBATIS never uses AutoCommit.

2) setCommitRequired has nothing to do with AutoCommit.  iBATIS uses
deferred commits to avoid unecessary commits when no non-queries have
been issued.  And setCommitRequired is actually parameterized and can
be set with <transactionManager ... commitRequired="true">

3) You'll need to post your code so we can see what it's doing.  Are
you calling startTransaction()?  Are you using setUserConnection?  Or
openSession(conn)?

I'm sure with the right information we can resolve this for you easily.

Clinton

On 1/18/07, Yuvraj Shinde <Yu...@sos.sungard.com> wrote:
>
>
>
>
> Hi all,
>
>
>
>    I want to know how to handle auto commit in ibatis.if I am saving two
> records and if I get an exception while saving second record the first
> record saved should be rolled back.
>
>   But ibatis is saving the first record. How I should handle this even
> though the auto commit property is explicitly set to false.
>
>
>
>    Even though AutoCommit value is set to false. Rollback of Transaction is
> not working.
>
>    I found one Issue in GeneralStatement.java.
>
>    On line 52  request.getSession().setCommitRequired(true);
>
>
>
>    Here Auto commit is hard coded it should be parameterized so that it will
> take value from "Auto commit" property of  SqlMapConfig.xml.
>
>    Please correct me if I am wrong.please send me a solution.
>
>
>
> Regards
>
> Yuvrajs
>
>
>
>
>
>
>
>
>
> 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.
>
>

RE: Autocommit not properly handled in Ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
I am using Oracle 9 database.

 

________________________________

From: Koka Kiknadze [mailto:226057@gmail.com] 
Sent: Friday, January 19, 2007 4:35 PM
To: user-java@ibatis.apache.org
Subject: Re: Autocommit not properly handled in Ibatis.

 

Your code is fine and it should work. Problem is elsewhere. Most
probably autocommit is still on for some reasons (maybe your database
does not support transactions at all?)

> failure is never final
Hope you'll work it out


Re: Autocommit not properly handled in Ibatis.

Posted by Koka Kiknadze <22...@gmail.com>.
Your code is fine and it should work. Problem is elsewhere. Most probably
autocommit is still on for some reasons (maybe your database does not
support transactions at all?)

>*failure is never final
*Hope you'll work it out

RE: Autocommit not properly handled in Ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
Hi Daniele,

  We don't have any method in session for rollback.

Regards
 yuvrajs

-----Original Message-----
From: Daniele Cremonini [mailto:daniele.cremonini@tiscali.it] 
Sent: Friday, January 19, 2007 3:43 PM
To: user-java@ibatis.apache.org
Subject: Re: Autocommit not properly handled in Ibatis.

You should put a rollback instruction in the catch section.

Daniele

Yuvraj Shinde wrote:
>
> 	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);
> 				
> 			}
> 		}
> 		
> 	}
>
>   



Re: Autocommit not properly handled in Ibatis.

Posted by Daniele Cremonini <da...@tiscali.it>.
You should put a rollback instruction in the catch section.

Daniele

Yuvraj Shinde wrote:
>
> 	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);
> 				
> 			}
> 		}
> 		
> 	}
>
>   


Re: Autocommit not properly handled in Ibatis.

Posted by Jeff Butler <je...@gmail.com>.
What is the getSession() method doing?  I'll wager that it is actually
creating a new session everytime it is called.  This would explain the
error.  Is there some reason you are trying to use the session directly?  We
hope and expect that this is a rarely used feature in iBATIS.

I echo the call for a more complete code example.

Jeff Butler


On 1/19/07, Yuvraj Shinde <Yu...@sos.sungard.com> wrote:
>
>
> Hi,
>
> For good data also it is also throwing exception in EndTransaction.
>
> I debugged the code it is throwing exception on
> session.endTransaction();
>
> ie   throw new TransactionException("TransactionManager could not
> commit.
>   No transaction is started.");
>
> in commit method of TransactionManager.java at line no 80.
> Do you have any idea.
>
> Regards
> yuvrajs
>
>
>
>
> -----Original Message-----
> From: Giovanni Cuccu - CUP2000 [mailto:giovanni.cuccu@cup2000.it]
> Sent: Friday, January 19, 2007 5:15 PM
> To: user-java@ibatis.apache.org
> Subject: Re: Autocommit not properly handled in Ibatis.
>
> 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
>
>
>

Re: simple delete not working in ibatis.

Posted by Stefan Langer <ma...@googlemail.com>.
Yuvraj Shinde wrote:
>    A simple delete is not working in ibatis.i am opening a new session
> and deleting the record but still it is not working.do you have any
> idea.all ibatis configuration is properly handled
A code snippet (SQL and SourceCode) could help locate the problem more 
easily.

Regards
Stefan

simple delete not working in ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
   A simple delete is not working in ibatis.i am opening a new session
and deleting the record but still it is not working.do you have any
idea.all ibatis configuration is properly handled.






RE: Autocommit not properly handled in Ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
Hi Giovanni Cuccu,

 It is working now I have saved the reference and it is working now.
Thanks a lot.

Regards
yuvrajs


Thanks you sir 

It is working with saved session



I'm not expert of iBatis code but there some chances that you are using
different sessions for your operation, this would explain the error you
get.
Try to save a reference to the session obtained in the first openSession
and reuse it to commit and end the transaction.
Giovanni

-----Original Message-----
From: Giovanni Cuccu - CUP2000 [mailto:giovanni.cuccu@cup2000.it] 
Sent: Friday, January 19, 2007 7:22 PM
To: user-java@ibatis.apache.org
Subject: Re: Autocommit not properly handled in Ibatis.

I tried to get a look to ibatis 2.3 source code and the method 
opensession is implemented in this way:
   public SqlMapSession getSession() {
     log.warn("Use of a deprecated API detected. 
SqlMapClient.getSession() is deprecated.  Use SqlMapClient.openSession()

instead.");
     return openSession();
   }

I'm not expert of iBatis code but there some chances that you are using 
different sessions for your operation, this would explain the error you
get.
Try to save a reference to the session obtained in the first openSession

and reuse it to commit and end the transaction.
Giovanni

> Hi,
> 
>   For good data also it is also throwing exception in EndTransaction.
> 
>   I debugged the code it is throwing exception on
> session.endTransaction();
> 
>   ie   throw new TransactionException("TransactionManager could not
> commit.      
>    No transaction is started.");
> 
>   in commit method of TransactionManager.java at line no 80.
>   Do you have any idea.
> 
> Regards
> yuvrajs
> 
> 
> 


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




Re: Autocommit not properly handled in Ibatis.

Posted by Giovanni Cuccu - CUP2000 <gi...@cup2000.it>.
I tried to get a look to ibatis 2.3 source code and the method 
opensession is implemented in this way:
   public SqlMapSession getSession() {
     log.warn("Use of a deprecated API detected. 
SqlMapClient.getSession() is deprecated.  Use SqlMapClient.openSession() 
instead.");
     return openSession();
   }

I'm not expert of iBatis code but there some chances that you are using 
different sessions for your operation, this would explain the error you get.
Try to save a reference to the session obtained in the first openSession 
and reuse it to commit and end the transaction.
Giovanni

> Hi,
> 
>   For good data also it is also throwing exception in EndTransaction.
> 
>   I debugged the code it is throwing exception on
> session.endTransaction();
> 
>   ie   throw new TransactionException("TransactionManager could not
> commit.      
>    No transaction is started.");
> 
>   in commit method of TransactionManager.java at line no 80.
>   Do you have any idea.
> 
> Regards
> yuvrajs
> 
> 
> 


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


RE: Autocommit not properly handled in Ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
Hi,

  For good data also it is also throwing exception in EndTransaction.

  I debugged the code it is throwing exception on
session.endTransaction();

  ie   throw new TransactionException("TransactionManager could not
commit.      
   No transaction is started.");

  in commit method of TransactionManager.java at line no 80.
  Do you have any idea.

Regards
yuvrajs




-----Original Message-----
From: Giovanni Cuccu - CUP2000 [mailto:giovanni.cuccu@cup2000.it] 
Sent: Friday, January 19, 2007 5:15 PM
To: user-java@ibatis.apache.org
Subject: Re: Autocommit not properly handled in Ibatis.

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



Re: Autocommit not properly handled in Ibatis.

Posted by Giovanni Cuccu - CUP2000 <gi...@cup2000.it>.
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


RE: Autocommit not properly handled in Ibatis.

Posted by Yuvraj Shinde <Yu...@sos.sungard.com>.
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 


   

-----Original Message-----
From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Friday, January 19, 2007 12:23 PM
To: user-java@ibatis.apache.org
Subject: Re: Autocommit not properly handled in Ibatis.

A few things:

1) iBATIS never uses AutoCommit.

2) setCommitRequired has nothing to do with AutoCommit.  iBATIS uses
deferred commits to avoid unecessary commits when no non-queries have
been issued.  And setCommitRequired is actually parameterized and can
be set with <transactionManager ... commitRequired="true">

3) You'll need to post your code so we can see what it's doing.  Are
you calling startTransaction()?  Are you using setUserConnection?  Or
openSession(conn)?

I'm sure with the right information we can resolve this for you easily.

Clinton

On 1/18/07, Yuvraj Shinde <Yu...@sos.sungard.com> wrote:
>
>
>
>
> Hi all,
>
>
>
>    I want to know how to handle auto commit in ibatis.if I am saving
two
> records and if I get an exception while saving second record the first
> record saved should be rolled back.
>
>   But ibatis is saving the first record. How I should handle this even
> though the auto commit property is explicitly set to false.
>
>
>
>    Even though AutoCommit value is set to false. Rollback of
Transaction is
> not working.
>
>    I found one Issue in GeneralStatement.java.
>
>    On line 52  request.getSession().setCommitRequired(true);
>
>
>
>    Here Auto commit is hard coded it should be parameterized so that
it will
> take value from "Auto commit" property of  SqlMapConfig.xml.
>
>    Please correct me if I am wrong.please send me a solution.
>
>
>
> Regards
>
> Yuvrajs
>
>
>
>
>
>
>
>
>
> 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.
>
>



Re: Autocommit not properly handled in Ibatis.

Posted by Clinton Begin <cl...@gmail.com>.
A few things:

1) iBATIS never uses AutoCommit.

2) setCommitRequired has nothing to do with AutoCommit.  iBATIS uses
deferred commits to avoid unecessary commits when no non-queries have
been issued.  And setCommitRequired is actually parameterized and can
be set with <transactionManager ... commitRequired="true">

3) You'll need to post your code so we can see what it's doing.  Are
you calling startTransaction()?  Are you using setUserConnection?  Or
openSession(conn)?

I'm sure with the right information we can resolve this for you easily.

Clinton

On 1/18/07, Yuvraj Shinde <Yu...@sos.sungard.com> wrote:
>
>
>
>
> Hi all,
>
>
>
>    I want to know how to handle auto commit in ibatis.if I am saving two
> records and if I get an exception while saving second record the first
> record saved should be rolled back.
>
>   But ibatis is saving the first record. How I should handle this even
> though the auto commit property is explicitly set to false.
>
>
>
>    Even though AutoCommit value is set to false. Rollback of Transaction is
> not working.
>
>    I found one Issue in GeneralStatement.java.
>
>    On line 52  request.getSession().setCommitRequired(true);
>
>
>
>    Here Auto commit is hard coded it should be parameterized so that it will
> take value from "Auto commit" property of  SqlMapConfig.xml.
>
>    Please correct me if I am wrong.please send me a solution.
>
>
>
> Regards
>
> Yuvrajs
>
>
>
>
>
>
>
>
>
> 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.
>
>