当我尝试输入无效值(值<1和> 19)时出现以下错误,但是如果我尝试输入有效值(1到19之间),一切正常。
Validation failed for classes [univ_orientation.dz.Entity.Semester] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='must be greater than or equal to 1', propertyPath=Moyenne, rootBeanClass=class univ_orientation.dz.Entity.Semester, messageTemplate='{javax.validation.constraints.Min.message}'}
]
`
@Entity
@Table(name="Semester")
public class Semester {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="idSemester")
private int idSemester;
@Column(name="SemesterNumber")
private int SemesterNumber;
@NotNull
@Min(1)
@Max(19)
@Column(name="Moyenne")
private double Moyenne;
@Column(name="Credit")
private int Credit;
@Column(name="Session")
private String Session;
@ManyToOne( cascade= {CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH},
fetch=FetchType.EAGER)
@JoinColumn(name="Student_idStudent")
private Student student;
// getter和setter
my dao
@Override
public void saveSemester(Semester semester){
try {
Session session = sessionFactory.getCurrentSession();
session.saveOrUpdate(semester);
}catch(Exception e) {
saveSemester: "+e.getMessage());
}
}
`