Steps for creating Group Validation Using Hibernate Validation

Viewed 3055

I don't really understand the steps for creating Group Validation using Hibernate. Please can anyone help. I have two classes from databases where some fields from both classes should be grouped and validated, using official hibernate docs I take next steps: Lets assume I have two classes with fields:

    public class Tickets implements Serializable {
    @NotNull(groups=GroupLotsAndTicketsValidation.class)
    @Size(groups = GroupLotsAndTicketsValidation.class)
    @NotBlank
    private string Amount;
    //and other fields..
    //getters and setters
    }

This was my first class. Here is the Second:

public class Lots implements Serializable {

@NotNull(groups = GroupLotsAndTicketsValidation.class)
@Size(groups = GroupLotsAndTicketsValidation.class)
@NotBlank(groups =GroupLotsAndTicketsValidation.class)
private String title;
@NotNull(groups = GroupLotsAndTicketsValidation.class)
@NotBlank(groups =GroupLotsAndTicketsValidation.class)
private String fullWeight;
//and other fields..
//getters and setters...
    }

This was My second class. Also I read that I should create one interface per class. However as I think It should be done if i want to create my own annotations. Should I create interfaces and what steps to take next. Thanks in advance

1 Answers
Related