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 jlaur <ja...@pepsi.com> on 2008/06/10 15:26:44 UTC

Help with what "commitRequired=true" param means

Hi,

We are using Ibatis vs 2.2.0, and are going thru the process of updating
our db to Oracle 10g.  We are noticing behavior (after the upgrade) in
our test env where our ibatis transactions do not commit.  Through some
research on the internet, we discovered that we were not providing the
"commitRequired=true" param to the transaction manager config found in
the sql-map-config.xml file.  When we did provide this param setting,
the transactions handled by ibatis would then commit.

 
<transactionManager type="JDBC" commitRequired="true" >
<!--Oracle DataSource  -->
<dataSource type="JNDI" >
<property name="DataSource" value="${urlOracle}"/>
<property name="Driver.SetBigStringTryClob" value="true" />			
</dataSource>
</transactionManager>



My question is :
What exactly does this param signify, and were we correct in its
application for the problem described above ?



Thanks greatly for your help,


Regards,

Jason. 


-- 
View this message in context: http://www.nabble.com/Help-with-what-%22commitRequired%3Dtrue%22-param-means-tp17755411p17755411.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help with what "commitRequired=true" param means

Posted by jlaur <ja...@pepsi.com>.
We propagate any db related errors upwards to our struts action class (struts
action class calls our business delegate) - where we do logging there.  In
the logs, we do not see any logged db errors assoc with the save.  We also
had our dba monitor the db connection for errors and he did not see anything
other than the fact that there was no commit assoc with the db connection
statements.  So, I'm pretty stumped ...

 

Nicholoz Koka Kiknadze wrote:
> 
> First of all I'd add catch block to log errors to your try/finally. In
> your
> code you do multiple inserts, so if any of them fails your whole
> transaction
> will roll back. I can see no other possible scenario :(
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-with-what-%22commitRequired%3Dtrue%22-param-means-tp17755411p17760574.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help with what "commitRequired=true" param means

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
First of all I'd add catch block to log errors to your try/finally. In your
code you do multiple inserts, so if any of them fails your whole transaction
will roll back. I can see no other possible scenario :(

Re: Help with what "commitRequired=true" param means

Posted by jlaur <ja...@pepsi.com>.
I have attached code from our application that shows the problem transaction. 
The business delegate code calls the sql map data access/dao code.

The transaction is an insert and so the reason why I am confused why it does
not commit unless I specify and set the aforementioned param to true.

I want to be sure that providing the param is indeed necessary and that I am
not just patching something that perhaps in a deeper issue pertaining to the
oracle 10g upgrade.

I don't know if this helps, but, I have a basic single table insert that is
executed by ibatis (no transaction involved) and that commits to the db with
no problems.

Thanks greatly. 



Nicholoz Koka Kiknadze wrote:
> 
> Here's extract from iBatis docs:
> 
> *Normally iBATIS will not commit transactions unless an insert, update, or
> delete operation has been
> performed. This is true even if you explicitly call the
> commitTransaction()
> method. This behavior
> creates problems in some cases. If you want iBATIS to always commit
> transactions, even if no insert,
> update, or delete operation has been performed, then set the value of the
> commitRequired attribute to true.
> Examples of where this attribute is useful include:
>     1.   If you call a stored procedures that updates data as well as
> returning rows. In that case you would
>          call the procedure with the queryForList() operation – so iBATIS
> would not normally commit the
>          transaction. But then the updates would be rolled back.
>     2.   In a WebSphere environment when you are using connection pooling
> and you use the JNDI
>          <dataSource> and the JDBC or JTA transaction manager. WebSphere
> requires all transactions on
>          pooled connections to be committed or the connection will not be
> returned to the pool.
> Note that the commitRequired attribute has no effect when using the
> EXTERNAL
> transaction manager.
> *
> So it does not explain why your transactions are not commited with
> commitRequired=false if you do call commitTransactio() after
> insert/update/delete (and I think you do not care about commiting after
> selects).
> 
> Could you provide sample transaction code from your app which you suspect
> does not commit ?
> 
> 
> 
> On Tue, Jun 10, 2008 at 5:26 PM, jlaur <ja...@pepsi.com> wrote:
> 
>>
>> Hi,
>>
>> We are using Ibatis vs 2.2.0, and are going thru the process of updating
>> our db to Oracle 10g.  We are noticing behavior (after the upgrade) in
>> our test env where our ibatis transactions do not commit.  Through some
>> research on the internet, we discovered that we were not providing the
>> "commitRequired=true" param to the transaction manager config found in
>> the sql-map-config.xml file.  When we did provide this param setting,
>> the transactions handled by ibatis would then commit.
>>
>>
>> <transactionManager type="JDBC" commitRequired="true" >
>> <!--Oracle DataSource  -->
>> <dataSource type="JNDI" >
>> <property name="DataSource" value="${urlOracle}"/>
>> <property name="Driver.SetBigStringTryClob" value="true" />
>> </dataSource>
>> </transactionManager>
>>
>>
>>
>> My question is :
>> What exactly does this param signify, and were we correct in its
>> application for the problem described above ?
>>
>>
>>
>> Thanks greatly for your help,
>>
>>
>> Regards,
>>
>> Jason.
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Help-with-what-%22commitRequired%3Dtrue%22-param-means-tp17755411p17755411.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 
http://www.nabble.com/file/p17757007/code.txt code.txt 
-- 
View this message in context: http://www.nabble.com/Help-with-what-%22commitRequired%3Dtrue%22-param-means-tp17755411p17757007.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help with what "commitRequired=true" param means

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
Here's extract from iBatis docs:

*Normally iBATIS will not commit transactions unless an insert, update, or
delete operation has been
performed. This is true even if you explicitly call the commitTransaction()
method. This behavior
creates problems in some cases. If you want iBATIS to always commit
transactions, even if no insert,
update, or delete operation has been performed, then set the value of the
commitRequired attribute to true.
Examples of where this attribute is useful include:
    1.   If you call a stored procedures that updates data as well as
returning rows. In that case you would
         call the procedure with the queryForList() operation – so iBATIS
would not normally commit the
         transaction. But then the updates would be rolled back.
    2.   In a WebSphere environment when you are using connection pooling
and you use the JNDI
         <dataSource> and the JDBC or JTA transaction manager. WebSphere
requires all transactions on
         pooled connections to be committed or the connection will not be
returned to the pool.
Note that the commitRequired attribute has no effect when using the EXTERNAL
transaction manager.
*
So it does not explain why your transactions are not commited with
commitRequired=false if you do call commitTransactio() after
insert/update/delete (and I think you do not care about commiting after
selects).

Could you provide sample transaction code from your app which you suspect
does not commit ?



On Tue, Jun 10, 2008 at 5:26 PM, jlaur <ja...@pepsi.com> wrote:

>
> Hi,
>
> We are using Ibatis vs 2.2.0, and are going thru the process of updating
> our db to Oracle 10g.  We are noticing behavior (after the upgrade) in
> our test env where our ibatis transactions do not commit.  Through some
> research on the internet, we discovered that we were not providing the
> "commitRequired=true" param to the transaction manager config found in
> the sql-map-config.xml file.  When we did provide this param setting,
> the transactions handled by ibatis would then commit.
>
>
> <transactionManager type="JDBC" commitRequired="true" >
> <!--Oracle DataSource  -->
> <dataSource type="JNDI" >
> <property name="DataSource" value="${urlOracle}"/>
> <property name="Driver.SetBigStringTryClob" value="true" />
> </dataSource>
> </transactionManager>
>
>
>
> My question is :
> What exactly does this param signify, and were we correct in its
> application for the problem described above ?
>
>
>
> Thanks greatly for your help,
>
>
> Regards,
>
> Jason.
>
>
> --
> View this message in context:
> http://www.nabble.com/Help-with-what-%22commitRequired%3Dtrue%22-param-means-tp17755411p17755411.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>