Re: How to set autoCommit to true

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

Luis Perez
Hi François,

     Thx for the answer. Perhaps I didn't make the correct question
(english it's not one of my best skills), i'don`t want to set
autoCommit explicity in each call, i want to set it to true by
default . Do you know if I can do that?

Thx,
Luis

On 27 ago, 14:07, François Schiettecatte <[hidden email]>
wrote:

> There are variations for the openSession() method which allows you to set autoCommit, from SqlSessionFactory.java:
>
>   SqlSession openSession();
>
>   SqlSession openSession(boolean autoCommit);
>   SqlSession openSession(Connection connection);
>   SqlSession openSession(TransactionIsolationLevel level);
>
>   SqlSession openSession(ExecutorType execType);
>   SqlSession openSession(ExecutorType execType, boolean autoCommit);
>   SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level);
>   SqlSession openSession(ExecutorType execType, Connection connection);
>
> François
>
> On Aug 27, 2010, at 4:31 AM, Luis Perez wrote:
>
> > Hi all,
>
> > Perhaps it's a silly question but, how can I set autoCommit to true?
> > I've  set the autoCommit property for the UNPOOLED datasource and the
> > defaultAutoCommit property for the POOLED datasource but the
> > openSession() method is allaway setting the value to false.
>
> > Thx in advance,
> > Luis
Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

François Schiettecatte
I don't think so, I don't think setting the autoCommit at a global level is possible in MyBatis, should be not difficult to add though, you could always ask for a change.

I put all my calls to openSession in a single class so I can use a flag (either hard coded or set in a config file) to control this, so it is not an issue for me.

François

On Aug 31, 2010, at 1:32 AM, Luis Perez wrote:

> Hi François,
>
>     Thx for the answer. Perhaps I didn't make the correct question
> (english it's not one of my best skills), i'don`t want to set
> autoCommit explicity in each call, i want to set it to true by
> default . Do you know if I can do that?
>
> Thx,
> Luis
>
> On 27 ago, 14:07, François Schiettecatte <[hidden email]>
> wrote:
>> There are variations for the openSession() method which allows you to set autoCommit, from SqlSessionFactory.java:
>>
>>   SqlSession openSession();
>>
>>   SqlSession openSession(boolean autoCommit);
>>   SqlSession openSession(Connection connection);
>>   SqlSession openSession(TransactionIsolationLevel level);
>>
>>   SqlSession openSession(ExecutorType execType);
>>   SqlSession openSession(ExecutorType execType, boolean autoCommit);
>>   SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level);
>>   SqlSession openSession(ExecutorType execType, Connection connection);
>>
>> François
>>
>> On Aug 27, 2010, at 4:31 AM, Luis Perez wrote:
>>
>>> Hi all,
>>
>>> Perhaps it's a silly question but, how can I set autoCommit to true?
>>> I've  set the autoCommit property for the UNPOOLED datasource and the
>>> defaultAutoCommit property for the POOLED datasource but the
>>> openSession() method is allaway setting the value to false.
>>
>>> Thx in advance,
>>> Luis

Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

Larry Meadors
You should be able to do it in your jdbc connection string.

You could also use the SqlSessionManager - it commits after each
action unless you explicitly start a transaction.

Larry
Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

Luis Perez
First, thanks for your time.

Unfortunately the Oracle driver does not support that option.

I'll try the SqlSessionManager.

Luis

On 31 ago, 16:07, Larry Meadors <[hidden email]> wrote:
> You should be able to do it in your jdbc connection string.
>
> You could also use the SqlSessionManager - it commits after each
> action unless you explicitly start a transaction.
>
> Larry
Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

Luis Perez
In reply to this post by François Schiettecatte
Thanks again.

We use MyBatis in an EJB container (Glassfish 3)  but the programers
prefer  to do the unit testing without it, relying in the autoCommit
behaviour of the Oracle driver.

I'll try the Larry solution.

On 31 ago, 14:42, François Schiettecatte <[hidden email]>
wrote:

> I don't think so, I don't think setting the autoCommit at a global level is possible in MyBatis, should be not difficult to add though, you could always ask for a change.
>
> I put all my calls to openSession in a single class so I can use a flag (either hard coded or set in a config file) to control this, so it is not an issue for me.
>
> François
>
> On Aug 31, 2010, at 1:32 AM, Luis Perez wrote:
>
> > Hi François,
>
> >     Thx for the answer. Perhaps I didn't make the correct question
> > (english it's not one of my best skills), i'don`t want to set
> > autoCommit explicity in each call, i want to set it to true by
> > default . Do you know if I can do that?
>
> > Thx,
> > Luis
>
> > On 27 ago, 14:07, François Schiettecatte <[hidden email]>
> > wrote:
> >> There are variations for the openSession() method which allows you to set autoCommit, from SqlSessionFactory.java:
>
> >>   SqlSession openSession();
>
> >>   SqlSession openSession(boolean autoCommit);
> >>   SqlSession openSession(Connection connection);
> >>   SqlSession openSession(TransactionIsolationLevel level);
>
> >>   SqlSession openSession(ExecutorType execType);
> >>   SqlSession openSession(ExecutorType execType, boolean autoCommit);
> >>   SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level);
> >>   SqlSession openSession(ExecutorType execType, Connection connection);
>
> >> François
>
> >> On Aug 27, 2010, at 4:31 AM, Luis Perez wrote:
>
> >>> Hi all,
>
> >>> Perhaps it's a silly question but, how can I set autoCommit to true?
> >>> I've  set the autoCommit property for the UNPOOLED datasource and the
> >>> defaultAutoCommit property for the POOLED datasource but the
> >>> openSession() method is allaway setting the value to false.
>
> >>> Thx in advance,
> >>> Luis
Reply | Threaded
Open this post in threaded view
|

Re: How to set autoCommit to true

Clinton Begin
Administrator
Fwiw:  that's a terrible way to test.  Using autocommit changes the
scope of your transactions.  Most people ust either a simple
container, or even just the setup and teardown type methods of a unit
test to create and end the transaction.

That said, if you really want to use autocommit by default, just
decorate the SqlSessionFactory and override the behavior of the
parameterless openSession().

Cheers,
clinton

On 2010-09-01, Luis Perez <[hidden email]> wrote:

> Thanks again.
>
> We use MyBatis in an EJB container (Glassfish 3)  but the programers
> prefer  to do the unit testing without it, relying in the autoCommit
> behaviour of the Oracle driver.
>
> I'll try the Larry solution.
>
> On 31 ago, 14:42, François Schiettecatte <[hidden email]>
> wrote:
>> I don't think so, I don't think setting the autoCommit at a global level
>> is possible in MyBatis, should be not difficult to add though, you could
>> always ask for a change.
>>
>> I put all my calls to openSession in a single class so I can use a flag
>> (either hard coded or set in a config file) to control this, so it is not
>> an issue for me.
>>
>> François
>>
>> On Aug 31, 2010, at 1:32 AM, Luis Perez wrote:
>>
>> > Hi François,
>>
>> >     Thx for the answer. Perhaps I didn't make the correct question
>> > (english it's not one of my best skills), i'don`t want to set
>> > autoCommit explicity in each call, i want to set it to true by
>> > default . Do you know if I can do that?
>>
>> > Thx,
>> > Luis
>>
>> > On 27 ago, 14:07, François Schiettecatte <[hidden email]>
>> > wrote:
>> >> There are variations for the openSession() method which allows you to
>> >> set autoCommit, from SqlSessionFactory.java:
>>
>> >>   SqlSession openSession();
>>
>> >>   SqlSession openSession(boolean autoCommit);
>> >>   SqlSession openSession(Connection connection);
>> >>   SqlSession openSession(TransactionIsolationLevel level);
>>
>> >>   SqlSession openSession(ExecutorType execType);
>> >>   SqlSession openSession(ExecutorType execType, boolean autoCommit);
>> >>   SqlSession openSession(ExecutorType execType,
>> >> TransactionIsolationLevel level);
>> >>   SqlSession openSession(ExecutorType execType, Connection connection);
>>
>> >> François
>>
>> >> On Aug 27, 2010, at 4:31 AM, Luis Perez wrote:
>>
>> >>> Hi all,
>>
>> >>> Perhaps it's a silly question but, how can I set autoCommit to true?
>> >>> I've  set the autoCommit property for the UNPOOLED datasource and the
>> >>> defaultAutoCommit property for the POOLED datasource but the
>> >>> openSession() method is allaway setting the value to false.
>>
>> >>> Thx in advance,
>> >>> Luis

--
Sent from my mobile device