ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Florin Manolache" <flo...@ecstend.com>
Subject Re:
Date Mon, 11 Jul 2005 15:17:27 GMT
Let's say I have 2 tables: BANK_ACCOUNT_1 and BANK_ACCOUNT_2 and 2 sequences 
of operations:
t1: "get_total_balance" which will read data for user x from the first 
table, then from the second table and compute the total
t2: "transfer" which will subtract a certain amount for user x from the 
first table (account entity) and add it to the second table (second account 

Now, if I don't use a transaction for t1 and only for t2, it is possible 
that during t1 execution, between the first read from first table and the 
second read from the second table, a t2 transaction to occur and commit, so 
the computed total balance will be incorrect. The solution is to use a 
transaction for t1 also, but in order to increase the performance, I should 
set the connection in the read-only mode before starting t1 transactions. Is 
there any way to do this in iBatis?


----- Original Message ----- 
From: "James, Steven" <Steven.James@logicacmg.com>
To: <user-java@ibatis.apache.org>
Cc: <florin@ecstend.com>
Sent: Monday, July 11, 2005 3:51 PM

> if i understand you you wish for the reads to get the same view if another 
> transaction is processing. eg if user a creates a connection then user b
> does so as well if b modifies but does not commit then a should not see 
> b's data until commit.
> If this is what you mean then you need to set the isolation level on the 
> transaction that is making changes. Your reader does not need a 
> transaction..
> Steve
> -----Original Message-----
> From: Florin Manolache [mailto:florin@ecstend.com]
> Sent: Mon 7/11/2005 10:32 AM
> To: cbegin@ibatis.com
> Cc: user-java@ibatis.apache.org
> Subject: Re: How to set the connection read-only?
> In my read-only transactions, I read data from multiple tables, and I want 
> to get a consistent view (I don't want other transactions which are not 
> read-only to modify data between 2 reads from 2 different tables). Setting 
> the transaction read-only is supposed to give hints to the database/driver 
> that I am not modifying anything, so it can perform transactions 
> optimizations.
> Basically what I need to do is to get a reference to the current 
> connection being used by DAOs and sqlMap and call setReadOnly(true) on it.
> Thanks,
> Florin
>  ----- Original Message ----- 
>  From: Clinton Begin
>  To: user-java@ibatis.apache.org ; Florin Manolache
>  Sent: Saturday, July 09, 2005 11:59 PM
>  Subject: Re: How to set the connection read-only?
>  Florin,
>  I don't understand why you would do that.  If you have a connection 
> that's read-only, why would you need a transaction at all? (or vice versa)
>  Cheers,
>  Clinton
>  On 7/8/05, Florin Manolache <florin@ecstend.com> wrote:
>    Is there a way to set the connection in the read-only state before 
> starting a transaction?
>    I'm using a mix of DAOs and sqlMaps in my application so I'm interested 
> in a solution for both of them.
>    Thanks,
>    Florin
> This e-mail and any attachment is for authorised use by the intended 
> recipient(s) only. It may contain proprietary material, confidential 
> information and/or be subject to legal privilege. It should not be copied, 
> disclosed to, retained or used by, any other party. If you are not an 
> intended recipient then please promptly delete this e-mail and any 
> attachment and all copies and inform the sender. Thank you.

View raw message