Marian
Marian

Reputation: 85

Concurrency problems in DB

Currently I have next relation in DB parent:

@Entity
class Parent{

@OneToMany
private List<Child> childs;
}

and child

@Entity
class Child{

@ManyToOne
private Parent parent;
}

In case where two users at the same time will work on the one child element from the same list and save it in the same time. Will we have some problem with concurrency?

Upvotes: 1

Views: 45

Answers (1)

Yogi
Yogi

Reputation: 1895

You need to use Isolation Level ON your methods for entities.

@Transactional(isolation = Isolation.READ_COMMITTED)

For reading and understanding of Isolationlevels:

  1. https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/transaction/annotation/Isolation.htm

Upvotes: 1

Related Questions