title: Spring Data Rest Put not updating with immutable entity on SpringBoot 2.1.x
body: <p>After updating to the spring boot starter version 2.1.5 put requests don't update the entity anymore with immutable entities.</p>
  
  <p>Put requests work on spring boot starter 2.0.3 but not on 2.1.4 &amp; 2.1.5. Using the Patch method however works fine.</p>
  
  <p>Since I am working in Kotlin my code is written in Kotlin but I can also reproduce this with a Java entity:</p>
  
  <p>Given the entites:</p>
  
  <pre><code>@Entity
  data class MyEntityKt(
       @Id
       @GeneratedValue
       val id: UUID? = null,
       @Version
       val version: Long = 0,
       val name: String = "",
       val description: String = ""
  )
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Value
  @Wither
  @Entity
  @RequiredArgsConstructor
  public class MyEntityJava {
  
      public MyEntityJava() {
          id = null;
          version = 0;
          name = "";
          description = "";
      }
  
      @Id
      @GeneratedValue
      private final UUID id;
      @Version
      private final long version;
      private final String name;
      private final String description;
  }
  </code></pre>
  
  <p>And the two corresponding RestRepositories:</p>
  
  <pre><code>@RepositoryRestResource(path = "kotlin")
  interface MyEntityRepository : JpaRepository&lt;MyEntityKt, UUID&gt;
  
  @RepositoryRestResource(path = "java")
  interface ImmutableEntityRepository : JpaRepository&lt;MyEntityJava, UUID&gt;
  </code></pre>
  
  <p>And in my test (<code>@SpringBootTest</code>) I try the following:</p>
  
  <pre><code>@Test
  fun testPut() {
      val myEntity = myEntityRepository.save(MyEntityKt(name = "TestName", description = "TestDescription"))
      val update = this.mockMvc.perform(
          put("/kotlin/${myEntity.id}")
              .accept(MediaType.APPLICATION_JSON_UTF8)
              .contentType(MediaType.APPLICATION_JSON_UTF8)
              .content(
                  """
                  {
                      "name": "TestNameModified",
                      "description": "TestDescriptionModified"
                  }
              """.trimIndent()
              )
      )
      .andReturn().response.contentAsByteArray.let { objectMapper.readValue(it, MyEntityKt::class.java) }
  
      val updatedEntity = myEntityRepository.findById(myEntity.id!!).get()
  
      assertThat(updatedEntity.name).isEqualTo("TestNameModified")    
      assertThat(updatedEntity.description).isEqualTo("TestDescriptionModified")
  }
  </code></pre>
  
  <p>Also the response I get is:</p>
  
  <pre><code>{
      "name" : "TestName",
      "description" : "TestDescription",
      "_links" : {
      "self" : {
          "href" : "http://localhost/kotlin/fd83f256-3515-41b0-b9c7-7bfe53a367f8"
      },
      "myEntityKt" : {
          "href" : "http://localhost/kotlin/fd83f256-3515-41b0-b9c7-7bfe53a367f8"
      }
  }
  </code></pre>
  
  <p>I did some investigation and <code>org.springframework.data.rest.webmvc.json.DomainObjectReader.MergingPropertyHandler#doWithPersistentProperty</code> which I guess would be responsible for creating an updated version of my entity to persist, seems like it is only setting the values on the accessor but not actually creating an updated object.</p>
  
  <p>On spring boot version 2.0.3 the test case passes, on 2.1.5 however the entity is not updated, and there is no actual reason given (eg, log output) why the entity is not updated. My guess is that it has something to do with the fact that the entites are immutable but I don`t see why this worked previously.</p>
  
  <p>EDIT: I uploaded the testcase to <a href="https://github.com/Tree4Free/SpringDataRestProblemTestCase" rel="nofollow noreferrer">Github</a></p>