OptimisticLocking and @OneToMany (mappedBy = ...)?

I have an AbstractEntity class as a superclass for all my entites, which defines an optimistic locking column as follows:

@Version
private long lockVersion;

Now I often get OptimisticLockingExceptions for entities that only change in the same mappedBy ratio, similar to the following:

@OneToMany(mappedBy = Property.PROPERTY_DESCRIPTOR, cascade = { CascadeType.REMOVE })
private Set<Property> properties = new HashSet<Property>();

Can these collections be excluded from the optimistic Hibernate lock? An entity does not change in the database at all ... only others refer to it.

+3
source share
2 answers

(/ ) , , , @OptimisticLock :

@OptimisticLock(excluded=true)
@OneToMany(mappedBy = Property.PROPERTY_DESCRIPTOR, cascade = { CascadeType.REMOVE })
private Set<Property> properties = new HashSet<Property>();

, Hibernate JPA.

+2

, :

, , , .

0

Source: https://habr.com/ru/post/1721287/


All Articles