title: Issue with OptimisticLockType.DIRTY not working as expected
body: <pre><code>
  fun main(args: Array&lt;String&gt;)
  {
      runApplication&lt;JpaTest&gt;(*args).getBean(JpaTest::class.java).test()
  }
  
  @SpringBootApplication
  class JpaTest
  {
      @Autowired
      lateinit var repository: PersonRepository
  
      fun test()
      {
          repository.save(Person())
  
          runBlocking {
  
              suspend fun update(name: String, delay: Long)
              {
                  val p = repository.findById(1).get()
                  delay(delay)
  
                  println(&quot;=== $name&quot;)
                  p.name = name
                  repository.save(p)
              }
  
              withContext(Dispatchers.Default) {
                  awaitAll(
                      async { update(&quot;Right Name&quot;, 3000) },
                      async { update(&quot;Wrong Name&quot;, 5000) }
                  )
  
                  println(&quot; &quot;)
                  val p = repository.findById(1).get()
                  println(&quot;Final: $p&quot;)
                  println(&quot; &quot;)
              }
          }
  
          exitProcess(0)
      }
  }
  
  @Repository
  interface PersonRepository : CrudRepository&lt;Person, Long&gt;
  
  @Entity
  @DynamicUpdate
  @OptimisticLocking(type=OptimisticLockType.DIRTY)
  data class Person(
      @Id
      @GeneratedValue
      val id: Long = 0,
  
      var name: String = &quot;?&quot;,
  )
  </code></pre>
  <p>I'm trying to simulate a multi-threaded environment (or multiple instances of the same app running) <strong>where an entity is fetch from the database at the same time</strong>, changed and persisted.</p>
  <p>When the first save task runs (3s later):</p>
  <pre><code>=== Right Name
  Hibernate: select person0_.id as id1_0_0_, person0_.name as name2_0_0_ from person person0_ where person0_.id=?
  2021-03-24 09:18:38.565 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
  2021-03-24 09:18:38.566 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name2_0_0_] : [VARCHAR]) - [UNKNOWN]
  Hibernate: update person set name=? where id=? and name=?
  2021-03-24 09:18:38.567 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [Right Name]
  2021-03-24 09:18:38.568 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [BIGINT] - [1]
  2021-03-24 09:18:38.568 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [UNKNOWN]
  </code></pre>
  <p>When the second save task runs (5s later):</p>
  <pre><code>=== Wrong Name
  Hibernate: select person0_.id as id1_0_0_, person0_.name as name2_0_0_ from person person0_ where person0_.id=?
  2021-03-24 09:18:40.556 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
  2021-03-24 09:18:40.556 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name2_0_0_] : [VARCHAR]) - [Right Name]
  Hibernate: update person set name=? where id=? and name=?
  2021-03-24 09:18:40.557 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [Wrong Name]
  2021-03-24 09:18:40.557 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [BIGINT] - [1]
  2021-03-24 09:18:40.557 TRACE 21791 --- [atcher-worker-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [Right Name]
  </code></pre>
  <p>Please note that both tasks fetched the database for the same object and then slept for 3s/5s before updating/saving.</p>
  <p>The issue here is that the <code>second task</code> <strong>fetched the database again</strong> before updating, meaning that the <code>first task</code> changes are lost. I tried adding <code>@SelectBeforeUpdate(false)</code> but it also didn't work.</p>
  <p>I was expecting that when <code>second task</code> attempted to persist the entity, an <code>OptimisticLockException</code> would be thrown.</p>
  <p>If I change the lockType to <code>VERSION</code> it works as expected and <code>second task</code>'s update is rejected. Why is that?</p>