Questions tagged [pessimistic]
12 questions
73
votes
5 answers
What's the difference between PESSIMISTIC_READ and PESSIMISTIC_WRITE in JPA?
I have read the article Locking and Concurrency in Java Persistence 2.0, and run the sample application. But I still can't realize the difference between PESSIMISTIC_READ and PESSIMISTIC_WRITE. I tried to modify the code, and where the code using…

paka
- 739
- 1
- 5
- 3
17
votes
4 answers
when is a pessimistic lock released in rails?
Assuming I'm doing something like this (from the Active Record Querying guide)
Item.transaction do
i = Item.first(:lock => true)
i.name = 'Jones'
i.save
end
Is the lock automatically released at the end of the transaction? I've looked…

user26270
- 6,904
- 13
- 62
- 94
9
votes
1 answer
How to release a locked row using JPA?
I'm using the EclipseLink implementation of the JPA 2.0 which allows pessimistic locking. I know how to lock an entity but how do I release the lock? At first I thought this was all taken care of within a transaction (in other words, the entity is…

Andre
- 243
- 3
- 8
5
votes
3 answers
Pessimistic lock in T-SQL
If i SELECT a row for updating in MS SQL Server, and want to have it locked till i either update or cancel, which option is better :-
1) Use a query hint like UPDLOCK
2) Use REPEATABLE READ isolation level for the transaction
3) any other…
Chakravarthy R
5
votes
3 answers
"SELECT ... FOR UPDATE" not working for Hibernate and MySQL
We have a system in which we must use pessimistic locking in one entity. We are using hibernate, so we use LockMode.UPGRADE. However, it does not lock.
The tables are InnoDB
We have checked that locking works correctly in the database (5.0.32), so…

Andres Rodriguez
- 111
- 1
- 7
2
votes
1 answer
Business application - pessimistic concurrency using messaging
We are using messaging in a project of ours to implement pessimistic concurrency. This means that if messaging goes down (channel goes down), concurrency goes down.
Is this done in other business applications?
Do you close the application (log…

Lieven Cardoen
- 25,140
- 52
- 153
- 244
1
vote
1 answer
Laravel error Lock database vs Transaction break
Anyone help me, please!.
In my project, i have transaction with lock record:
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Testing extends Command {
protected function handling()
{
DB::beginTransaction();
…

huy hoang
- 43
- 3
1
vote
1 answer
Doctrine (postgresql) Pessimistic Locking - doesn't throw PessimisticLockException
I try to use Pessimistic Locking with Doctrine ORM for PostgreSql.
Doctrine and PostgreSql with default configurations (without any changes).
This is code example (Symfony Command).
$sleep - this is time in seconds
$manager =…

Dmytro
- 572
- 9
- 29
0
votes
1 answer
table per client in database
We developing service were for each client user can make appointment.
Is there strategy - table in database (MS SQL SERVER) for each client will be proper?
We think such strategy simplifies and exclude complex table locking.

Alexandr
- 1,452
- 2
- 20
- 42
0
votes
3 answers
ASP.NET session object lifetime pessimistic assumption !
I check a session object and if it does exist then call another method which would use that object indirectly. Although the second method would access this object in a few nanoseconds I was thinking of a situation when the object exactly expires…

Xaqron
- 29,931
- 42
- 140
- 205
0
votes
2 answers
C++ - Are const parameters and class variables pessimization?
I'm trying to figure out when const should be used when writing C++ code. Are these all examples of pessimization or is it beneficial to write code this way?:
Example 1:
int findVal(const int OTHER_VAL) const
{
switch(OTHER_VAL)
{
case…

Matthew D. Scholefield
- 2,977
- 3
- 31
- 42
0
votes
0 answers
Grails pessimistic locking
I'm trying to permform a lock on an entity inside a service in Grails.
The code:
TheEntity entityForUpdate = TheEntity.lock(entityId)
(...) // some code
entityForUpdate.save()
This code works until a concurrent acces ocurs.
When it happens, one…

xabedev
- 31
- 3