title: Lombok Builder with defaults in Spring Data
body: <p>I have the following (simplified) class:</p>
  
  <pre><code>@Entity
  @Data
  @Builder
  @NoArgsConstructor // @Builder creates the all-args version but I need this one elsewhere.
  @AllArgsConstructor(access = AccessLevel.PRIVATE) // Having @NoArgsConstructor disables the @AllArgsConstructor needed by @Builder unless I have this explicitly applied
  public class MyClass {
  
    // ...
    @Builder.Default
    private String foo = "Some Default Value"
    // ...
  
  }
  </code></pre>
  
  <p>This works fine in the general case, but a problem comes about when this Entity gets built by Spring (specifically Spring Data Repository in response to a REST request to create it).  Spring sees the all-args constructor and uses it, setting a null value for foo (in this case it wasn't set in the POST data) and I end up with a null value for foo instead of the expected <code>"Some Default Value"</code>.  The <code>@Builder.Default</code>.</p>
  
  <p>It does not work to simply create the setter and prevent nulls.  I could write out the AllArgsConstructor explicitly, but that (somewhat) defeats the purpose of Lombok to some extent.  Not a horrible solution, but not ideal.</p>
  
  <p>Can anyone think of any workarounds for this?</p>