I have an entity XYZ.java
@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 interface XYZCRUD.java
to do CRUD operations on XYZ.java
@Validated
public interface XYZCRUD {
public int insert(@Valid XYZ entity) throws SomeException;
Although javax's @Valid works for @NotNull validation but it does not support passing validation group as annotation attribute from the method from where i am triggering the validation . So I tried using @Validated annotation which does allow to pass groups via an attribute "value" like this
@Validated
public interface XYZCRUD {
public int insert(@Validated(value=SomeGroup.class) XYZ entity) throws SomeException;
However it does not trigger the validation at all.I tried after removing the groups attribute from the field and also from the trigger annotation.
Conclusion : @Validated does not trigger @NotNull
Questions :
- Why @Validated does not trigger the javax's @NotNull ? Am I doing something wrong or does it not support it?
- Is there any any other way? cannot implement custom validator
NOTE : I am also using lombok if it has something to do with this.