title: @CreatedBy and @LastModifiedBy set actual entity instead of id
body: <p>I have an entity which looks like:</p>
  
  <pre><code>@Audited
  @Data
  @MappedSuperclass
  @EntityListeners(AuditingEntityListener.class)
  public abstract class BaseEntity {
  
    public static final long UNSAVED = 0;
  
    @Id
    @GeneratedValue
    private long id;
  
    @CreatedDate
    @Column(name = "created_at", updatable = false)
    private ZonedDateTime createdAt;
  
    @CreatedBy
    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "created_by")
    private User createdBy;
  
    @LastModifiedDate
    private ZonedDateTime updatedAt;
  
    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "updated_by")
    @LastModifiedBy
    private User updatedBy;
  
  }
  </code></pre>
  
  <p>I'm want @LastModifiedBy and @CreatedBy so that they set corresponding users. However, when I try to save the entity, I get an exception:</p>
  
  <pre><code>java.lang.ClassCastException: Cannot cast java.lang.Long to com.intranet.users.Users
  </code></pre>
  
  <p>So it seems to me that it tries to set not actual User, but it's id. Is there any way to make spring set actual User on the entity and not just it's id?</p>
  
  <p>Thanks</p>