title: spring data auditing fields marked as updatable=false don't get set on the returned entity when updating
body: <p>I'm using Spring Data's annotations to add auditing data to my entities when they are saved or updated. When I create the entity the <code>createdBy</code>, <code>createdDate</code>, <code>lastModifiedBy</code> and <code>lastModifiedDate</code> get set on the object returned by <code>repository.save()</code>.</p>
  
  <pre><code>ResourceEntity(id=ebbe1f3d-3359-4295-8c83-63eab21c4753, createdDate=2018-09-07T21:11:25.797, lastModifiedDate=2018-09-07T21:11:25.797, createdBy=5855070b-866f-4bc4-a18f-26b54f896a4b, lastModifiedBy=5855070b-866f-4bc4-a18f-26b54f896a4b)
  </code></pre>
  
  <p>Unfortunately, when I call <code>repository.save()</code> to update an existing entity the object returned does not have the <code>createdBy</code> and <code>createdDate</code> set.</p>
  
  <pre><code> ResourceEntity(id=ebbe1f3d-3359-4295-8c83-63eab21c4753, createdDate=null, lastModifiedDate=2018-09-07T21:12:01.953, createdBy=null, lastModifiedBy=5855070b-866f-4bc4-a18f-26b54f896a4b)
  </code></pre>
  
  <p>All the fields are set correctly in the database and a call to <code>repository.findOne()</code> outside of my service class returns an object with all the fields set correctly.</p>
  
  <pre><code>ResourceEntity(id=ebbe1f3d-3359-4295-8c83-63eab21c4753, createdDate=2018-09-07T21:11:25.797, lastModifiedDate=2018-09-07T21:12:01.953, createdBy=5855070b-866f-4bc4-a18f-26b54f896a4b, lastModifiedBy=5855070b-866f-4bc4-a18f-26b54f896a4b)
  </code></pre>
  
  <p>But if I call <code>repository.findOne()</code> in the service right after calling <code>repository.save()</code> to update the entity I also get an object back with <code>createdBy</code> and <code>createdDate</code> set to null.</p>
  
  <p>Here is my entity:</p>
  
  <pre><code>@Entity(name = "resource")
  @EntityListeners(AuditingEntityListener.class)
  @Table(name = "resource")
  @Data
  @EqualsAndHashCode(of = "id")
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor(access = AccessLevel.PRIVATE)
  public class ResourceEntity {
  
  @Id
  @org.hibernate.annotations.Type(type = "org.hibernate.type.PostgresUUIDType")
  private UUID id;
  
  @CreatedDate
  @Column(nullable = false, updatable = false)
  private LocalDateTime createdDate;
  
  @LastModifiedDate
  private LocalDateTime lastModifiedDate;
  
  @CreatedBy
  @Column(nullable = false, updatable = false)
  @org.hibernate.annotations.Type(type = "org.hibernate.type.PostgresUUIDType")
  private UUID createdBy;
  
  @LastModifiedBy
  @org.hibernate.annotations.Type(type = "org.hibernate.type.PostgresUUIDType")
  private UUID lastModifiedBy;
  }
  </code></pre>
  
  <p>Here is my service:</p>
  
  <pre><code>@Component
  public class ResourceService {
  @Autowired
  private ResourceRepository resourceRepository;
  
  public ResourceEntity createResource(ResourceEntity resourceEntity) {
      return saveResource(resourceEntity);
  }
  
  public ResourceEntity updateResource(ResourceEntity resourceEntity) {
      return saveResource(resourceEntity);
  }
  
  public ResourceEntity getResource(UUID resourceId) {
      return resourceRepository.findOne(resourceId);
  }
  
  private ResourceEntity saveResource(ResourceEntity resourceEntity) {
      ResourceEntity savedResourceEntity = resourceRepository.save(resourceEntity);
      return savedResourceEntity;
  }
  }
  </code></pre>
  
  <p>Here is my test:</p>
  
  <pre><code>def "Test update"() {
      given:
      UUID id = aRandom.uuid()
      Resource resource = aRandom.resource().id(id).build()
      Resource savedResource = resourceClient.createResource(resource)
  
      when:
      Resource updatedResource = aRandom.resource().id(id).build()
      updatedResource = resourceClient.updateResource(updatedResource)
  
      then:
      Resource result = resourceClient.getResource(id)
      assert result.id == updatedResource.id
      assert result.createdBy == updatedResource.createdBy
      assert result.creationDate == updatedResource.creationDate
      assert result.lastModifiedBy == updatedResource.lastModifiedBy
      assert result.lastModifiedDate == updatedResource.lastModifiedDate
  }
  </code></pre>