The difference between @Max and @DecimalMax (and @Min and @DecimalMin)

What is the difference between @Max and @DecimalMax and @Min and @DecimalMin in Hibernate Validator?

Looking at Javadocs, they seem to apply the same restriction.

+7
source share
1 answer

If you look at the help documentation, you will see that @Min and @Max annotations affect Hibernate metadata, while @DecimalMin and @DecimalMax do not. Namely, they add control constraints (which effectively improves your relational mapping).

Also, @Max and @Min accept a long value, while @DecimalMax and @DecimalMin accept a string representation of BigDecimal (which makes them the only possible choice if you are dealing with large numbers that exceed Long.MAX_VALUE or are in the Long.MIN_VALUE section.

+14
source

All Articles