filmov
tv
Spring Boot JDBCTemplate Optimistic Locking Example with MySQL and Java Multithreading

Показать описание
I show you how to perform optimistic locking with Java, SpringBoot and MySQL.
Pessimistic Locking VS Optimistic Locking
JDBCTemplate Optimistic Locking
NamedParameterJdbcTemplate Optimistic Locking
DataSourceTransactionManager
@Transactional annotation
I demonstrate the persistence lost update problem by creating a demo spring boot application containing a REST API and a JDBC template persistence layer.
Optimistic database locking can be achieved with many techniques, some popular methods are with a version column, or a modified integer column.
As a relational database will guarantee the ACID properties, we will ensure that each database write is performed within a transaction (Read committed transaction propagation if fine).
Each transaction will add a where clause to the sql, the where condition will ensure that the row's current value has not changed. And therefore guaranteed that the row has not been updated between the read/write. (As long as all writes follow the same transaction / code path).
Enjoy the demo!
Lost update problem and solve
Java Transaction Propagation Levels
Database connection Transaction Isolation Levels
Concurrency Control
Java
SpringBoot
SpringFramework
RESTful Webservice
Tomcat HTTP Request Thread breakpoint analysis
HTTP concurrency example
properties file MySQL Datasource JDBCTemplate autoconfiguration
Subscribe for more great tech content!
Enjoy!
Philip
Video Location: Slieve League Cliffs - Ireland, Co Donegal.
Pessimistic Locking VS Optimistic Locking
JDBCTemplate Optimistic Locking
NamedParameterJdbcTemplate Optimistic Locking
DataSourceTransactionManager
@Transactional annotation
I demonstrate the persistence lost update problem by creating a demo spring boot application containing a REST API and a JDBC template persistence layer.
Optimistic database locking can be achieved with many techniques, some popular methods are with a version column, or a modified integer column.
As a relational database will guarantee the ACID properties, we will ensure that each database write is performed within a transaction (Read committed transaction propagation if fine).
Each transaction will add a where clause to the sql, the where condition will ensure that the row's current value has not changed. And therefore guaranteed that the row has not been updated between the read/write. (As long as all writes follow the same transaction / code path).
Enjoy the demo!
Lost update problem and solve
Java Transaction Propagation Levels
Database connection Transaction Isolation Levels
Concurrency Control
Java
SpringBoot
SpringFramework
RESTful Webservice
Tomcat HTTP Request Thread breakpoint analysis
HTTP concurrency example
properties file MySQL Datasource JDBCTemplate autoconfiguration
Subscribe for more great tech content!
Enjoy!
Philip
Video Location: Slieve League Cliffs - Ireland, Co Donegal.
Комментарии