When to explicitly rule out Optimistic Lock (Hibernate)?

Under what circumstances would it be advisable to explicitly exclude an optimistic lock from the @OneToMany relationship through Hibernate?

I read a post in Hibernate, which basically says that any updates to the child objects will cause an optimistic lock for the parent object, which is usually not required. The key word here, as a rule, is ... can someone explain more precisely when you will need or not need optimistic blocking on such relationships?

Here is a sample code to demonstrate an optimistic blocking exception:

// Bars - these are specifically excluded from optimist lock
// for the object, since we don't want to obtain optimistic
// lock when we add a new bar
@OptimisticLock(excluded = true)
@OneToMany
@JoinColumn(name = "FOO_ID", nullable = false, updatable = false)
private List<FooBar> bars = new LinkedList<FooBar>();
+5
source share
1 answer

, " " , "" , , . Order, OrderLine s, , .

, , . Topic Post .

, . , , " " , . , - , , " " ( , , Order - OrderLine).

"--" "" , "" , .

+8

All Articles