Re: Exception on get method clusterj
Arco van der Velden Wrote:
-------------------------------------------------------
> Hi,
>
> I assume you mean a boundary issue of BigDecimal.
Yes, that is what I meant.
> This isn't the case since this is a test
> application every transaction is adding 1 to the
> total attribute.
> When we test with 5000 transactions (spread over
> 16 threads) the error occurs but the value of
> total can not be over 5000 in this case.
> One thing to mention is after the error occurs the
> transaction isn't active anymore so it cannot be
> rolled back, because of the error.
Right. The code in your original message uses auto-commit so each session method begins a new transaction and either commits or rolls back before returning.
You mention that this code runs in multiple threads. The exception is possibly multi-thread related. How do you ensure that each thread has its own copy of the session and the positionsInterface object?
If you have multiple threads trying to update the same row in the database, the code won't work properly. In order to avoid multiple threads getting the same state and updating the row to the same (incorrect) value, you should use transactions and locking.
You should set the lock mode to EXCLUSIVE, begin a transaction, read the row, either insert or update the row, and commit (or roll back) the transaction. That will enforce the proper locking semantics.
Subject
Views
Written By
Posted
2073
April 09, 2015 09:16AM
862
April 17, 2015 08:34AM
1062
April 17, 2015 11:40AM
985
April 17, 2015 02:53PM
833
April 17, 2015 03:35PM
Re: Exception on get method clusterj
946
April 18, 2015 05:09PM
1304
April 20, 2015 01:46AM
902
April 20, 2015 11:03AM
704
April 21, 2015 05:43AM
1017
May 18, 2015 08:25PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.