JSR Bigdecimal Validation is not working with @Digits

113 views Asked by At

Hi I am trying to validate integer and precision part for one column. Its not validating at all against Bigdecimal value. My Database is Oracle. Its validating if i am changing the data type to String .

@Column(name = "L_MI_COVERAGE_PERCENT")
@Digits(integer=3, fraction=6, message = "MI Coverage Percent should be precision 9 and scale 6.")
private BigDecimal  miCoveragePercent;

My database Column is

L_MI_COVERAGE_PERCENT   NUMBER(9,6)

I am passing a value like this 100001.10 . When i am running the application i am getting error as

org.hibernate.exception.DataException: could not execute statement .

  ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
                Validator validator = factory.getValidator();
                Set<ConstraintViolation<Loans>> violations = 
  validator.validate(loans); 

I am not getting any violations , but other fields validations are happening and messages are coming back in violations object except miCoveragePercent. This is the only with Bigdecimal.

0

There are 0 answers