I have an XYZ.java object
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @ToString public class XYZ extends BaseEntity implements Serializable { @NotNull (groups = {Groups.Insert.class, Groups.Delete.class, Groups.Update.class, Groups.Select.class}) private String X;
and there is an XYZCRUD.java interface for performing CRUD operations on XYZ.java
@Validated public interface XYZCRUD { public int insert(@Valid XYZ entity) throws SomeException;
Although javax @Valid works for @NotNull validation, it does not support passing the validation group as an annotation attribute from the method from which I run validation. So I tried using the @Validated annotation, which allows you to pass groups through a value attribute like this
@Validated public interface XYZCRUD { public int insert(@Validated(value=SomeGroup.class) XYZ entity) throws SomeException;
However, it does not call a check at all. I tried to remove the group attribute from the field as well as from the trigger annotation.
Conclusion: @Validated does not call @NotNull
Questions:
- Why doesn't @Validated call javax @NotNull? Am I doing something wrong or not supporting it?
- Is there any other way? cannot implement custom validator
NOTE. I also use lombok if it has anything to do with this.
source share