I\'m using project Lombok together with Spring Data JPA.
Is there any way to connect Lombok @Builder with JPA default constructor?
Code:
If the annotations lombok.Tolerate on constructor and javax.validation.constraints.NotNull on some property are used at the same time, sonarqube will mark it as a critical error: PROPERTY is marked "javax.validation.constraints.NotNull" but is not initialized in this constructor.
If the project uses SpringData with JPA, it can be solved using org.springframework.data.annotation.PersistenceConstructor (Spring annotation, not JPA!)
Then, in combination with Lombok, annotations will be like this:
@RequiredArgsConstructor(onConstructor = @__(@PersistenceConstructor))
For Lombok builder you also need to add:
@Builder
@AllArgsConstructor