문제

I want to write a class validation. But the following does not result in an error. Why?

   class TestVO {
        @AssertTrue
        public boolean testDefault() {
            return false;
        }
    }

    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    errors = validator.validate(new TestVO());
    assertTrue(!errors.isEmpty()); //this fails. there are no errors! Why?
도움이 되었습니까?

해결책

To answer my own question, as this is probably usefull as knowledge base: hibernate validations do ONLY work on get() methods. So modifying above to getTestDefault() works.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top