Denis Rozhko
Denis Rozhko

Reputation: 70

Optimistic and Pessimistic Locking in JPA vs Isolation level

Why do we need locking if we can easily change for instance isolation level from READ_COMMITED to REPEATABLE_READ or SERIALIZABLE. Do we win a lot of in perfomance?

Should we up isolation level only and if only locking doesn't helps but actually I see that locking can help to avoid of changing isolation level at all.

It cause me a little bit confused)

Thanks for advance in help

Upvotes: -1

Views: 93

Answers (1)

Denis Rozhko
Denis Rozhko

Reputation: 70

Isolation level applied for whole transaction but lock can be applied for particular stetament. It means we can use READ_COMMITED and for particular query do use locking instead of use REPETABLE_READ and disadvantage all queries in frame of transaction.

Upvotes: 0

Related Questions