NotNull annotation preventing builds in spring boot application

Advertisements I am trying to run a spring boot app. I have a model class(Category) and a service class(CategoryService) corresponding to the model Category.java @Data @Entity public class Category implements Serializable { @Id @GeneratedValue private Integer id; @NotNull private String categoryName; @NotNull private Integer totalResourceCount; @NotNull private Integer categoryValue; @Column(updatable = false, nullable = false)… Read More NotNull annotation preventing builds in spring boot application

Lombok's @Value not working with additional constructor

Advertisements I am using Lombok’s @Value annotation like this: @Value public class Foo { int x; int y; } As per the official documentation, this should be equivalent to @Getter @FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE) @AllArgsConstructor @ToString @EqualsAndHashCode. So far everything looks good, I can check the code with a little test and see that the @AllArgsConstrucotr is… Read More Lombok's @Value not working with additional constructor

Syntax error for lombok Generic class , builder pattern and custom setter

Advertisements Following are the set of classes. import lombok.Builder; import lombok.Data; import java.util.Collection; import java.util.Collections; import java.util.List; @Data @Builder public class GenericClass<T> { //Omitted other attributes for brevity. private Class<T> elementClazz; @SuppressWarnings("rawtypes") private Class<? extends Collection> collectionClazz; private Collection<String> strings; /*BUILDER*/ public static class GenericClassBuilder { public GenericClassBuilder strings(Collection<String> strs) { if (strs == null)… Read More Syntax error for lombok Generic class , builder pattern and custom setter

No default constructor for entity

Advertisements I’m trying to create an API and i’ve made this code so far: @Builder @Data @Entity public class IcesiUser { @Id private UUID userId; private String firstName; private String lastName; private String email; private String phoneNumber; private String password; @OneToMany(mappedBy = "user") private List<IcesiAccount> accounts; @ManyToOne @JoinColumn(name = "icesi_role_role_id") private IcesiRole role;} This is… Read More No default constructor for entity

Add javadoc in annotations

Advertisements I’d like to add javadoc for an annotation, specifically for lombok. If I do this: /** * Custom constructor used only in <code>OrderMapper</code></p>. * @param totalValue single parameter necessary to pass on the information to frontend * @see <a href= "https://github.com/projectlombok/lombok/issues/1269">Implicit @RequiredArgsConstructor on @Data will be removed when using @NoArgsConstructor #1269</a> */ @RequiredArgsConstructor It… Read More Add javadoc in annotations

How should I fix "Expected 0 arguments but found 3" error if I want to use Lombok RequiredArgsConstructor annotation?

Advertisements I am using Spring, JPA, Java17, MySQL. IDE: IntelliJ IDEA 2022.2.4 JDK: Amazon Coretto 17.0.6 I am getting an error "Expected 0 arguments but found 3". (image) Here is my Article entity class code and I am using Lombok to remove boilerplate code. For some reason RequiredArgsConstructor annotation cannot be well managed in test… Read More How should I fix "Expected 0 arguments but found 3" error if I want to use Lombok RequiredArgsConstructor annotation?

Lombok's setter can't be called

Advertisements package com.example.marketing.semantics.entities; import com.example.marketing.general.entities.BaseEntity; import com.example.marketing.general.interfaces.Phraseable; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.*; @Entity @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder @Table(name = "extra_phrases", uniqueConstraints = {@UniqueConstraint(name = "unique_extra_phrase", columnNames = {"phrase"})}) public class ExtraPhraseEntity extends BaseEntity implements Phraseable { @NotNull @NotEmpty @Column(nullable = false, columnDefinition = "varchar(1000) default… Read More Lombok's setter can't be called

Error with Lombok's @Builder with generic typed field

Advertisements I am having issues creating a POJO using Lombok’s @Builder annotation and have it map to the expected type at runtime. Here’s my code: OperationResult.java import lombok.Builder; import lombok.Data; @Data @Builder public class OperationResult<D> { private D data; } OperationResultTest.java import org.junit.jupiter.api.Test; public class OperationResultTest { @Test public void testGenerics() { OperationResult<String> restult =… Read More Error with Lombok's @Builder with generic typed field

@JsonInclude(JsonInclude.Include.NON_NULL) is not working with Lombok

Advertisements I have a code in class: @Data @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class ApiModels { private String address; private String age; private String name; } When i’m trying to set only address: public class TestClass { ApiModels models = new ApiModels(); @Test void someMethod() { models.setAddress("Some address"); System.out.println(models); } } I see all this… Read More @JsonInclude(JsonInclude.Include.NON_NULL) is not working with Lombok