title: When to explicitly exclude Optimistic Locking (Hibernate)?
body: <p>Under what circumstances would it be appropriate to explicitly exclude optimistic locking from a @OneToMany relationship via Hibernate?</p>
  
  <p>I have been reading a post on Hibernate which basically says any updates to child entities will cause an optimistic lock on parent entity, which is typically unneeded. The key word here is <em>typically</em>... can anyone explain more precisely when you would or would not need optimistic locking on a relationship like this?</p>
  
  <p>Here is the code example given to demonstrate optimistic lock exclusion:</p>
  
  <pre><code>// 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&lt;FooBar&gt; bars = new LinkedList&lt;FooBar&gt;();
  </code></pre>