Spring Data Mongodb : Deserialize using builder

Viewed 386

I'm wondring if there's a way to configure spring data to use a builder to deserialise a document. Something like JsonPOJOBuilder or JsonDeserialize(builder = ADocumentBuilder) for jackson ?

In fact I'm using lombok with @SuperBuilder annotation like :

@Data
@RequiredArgConstrcutor
@SuperBuilder
public abstract class AttachementBase {
  private String a;
  private final String b; //maybe final
  private String c;
}
@Value
@SuperBuilder
@Document
public class Attachement extend AttachementBase{
  private String d;
}

Evething's works fine with the builder and how to use it, except when calling the AttachementRepository.findXX() Spring trys to call a constructor but it cannot find the appropriate one.

Lombok generates AttachementBuilder in the Attachement class and I want to use it to deserialise this document.

I do not want this post be related to lombok, i juste illustrated the use case. The question is how to use a builder to deserialize a document in Spring-data-mongodb ?

0 Answers
Related