You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to set a @Builder.Constructor where I have some @Nullable properties defined in an interface's method being implemented by the class.
I have this on my parent class:
@Value.Style(nullableAnnotation = "jakarta.annotation.Nullable")
public abstract class BaseEntity {
@Id
@GeneratedValue
@Nullable
public Long id;
...
}
and this interface that is share between the Entity and some DTOs:
public interface IUser {
@NotBlank
@Size(min = 3, max = 50)
String getName();
@Nullable
@Size(min = 3, max = 150)
String getSurname();
}
And I have this child class:
public class User extends BaseEntity implements IUser {
@Builder.Constructor
public User(@Builder.Parameter Long id, String name, String surname) {
super(id);
this.name = name;
this.surname = surname;
}
}
When I run a test where I create a new User without the surname, I got this error, signalizing that the @Nullable was not considered:
java.lang.IllegalStateException: Cannot build User, some of required attributes are not set [surname]
at com.app_mngt.entities.UserBuilder.checkRequiredAttributes(UserBuilder.java:202)
at com.app_mngt.entities.UserBuilder.build(UserBuilder.java:176)
at com.app_mngt.mappers.UserMapperTest.testEntityToDtoMapping(UserMapperTest.java:41)
Am I missing something ?
The text was updated successfully, but these errors were encountered:
cvgaviao
changed the title
jakarta.annotation.Nullable is not being considered for on Interface method.
jakarta.annotation.Nullable is not being considered
Jun 29, 2024
cvgaviao
changed the title
jakarta.annotation.Nullable is not being considered
jakarta.annotation.Nullable is not being considered with @Builder.Constructor
Jun 29, 2024
Hello,
I'm trying to set a @Builder.Constructor where I have some
@Nullable
properties defined in an interface's method being implemented by the class.I have this on my parent class:
and this interface that is share between the Entity and some DTOs:
And I have this child class:
When I run a test where I create a new User without the surname, I got this error, signalizing that the
@Nullable
was not considered:Am I missing something ?
The text was updated successfully, but these errors were encountered: