/*** Calibration Tool class *@authorWdmcygah **/ Public classValidationutils {Private StaticValidator Validator =validation.builddefaultvalidatorfactory (). Getvalidator (); Public Static<T>validationresult validateentity (T obj) {validationresult result=NewValidationresult (); Set<ConstraintViolation<T>> set = Validator.validate (Obj,default.class); if(Collectionutils.isnotempty (set)) {Result.sethaserrors (true); Map<String,String> errormsg =NewHashmap<string,string>(); for(constraintviolation<t>Cv:set) {Errormsg.put (Cv.getpropertypath (). toString (), Cv.getmessage ()); } result.seterrormsg (ERRORMSG); } returnresult; } Public Static<T>validationresult validateproperty (T obj,string PropertyName) {validationresult result=NewValidationresult (); Set<ConstraintViolation<T>> set = Validator.validateproperty (Obj,propertyname,default.class); if(Collectionutils.isnotempty (set)) {Result.sethaserrors (true); Map<String,String> errormsg =NewHashmap<string,string>(); for(constraintviolation<t>Cv:set) {Errormsg.put (propertyname, Cv.getmessage ()); } result.seterrormsg (ERRORMSG); } returnresult; }}
Hibernate validation Manual parameter check does not go through spring