开发者

Difference between @Max and @DecimalMax (and @Min and @DecimalMin)

开发者 https://www.devze.com 2023-02-13 10:36 出处:网络
What\'s the difference between @Max and @DecimalMax, and @Min and @DecimalMin in Hibernate Validator?

What's the difference between @Max and @DecimalMax, and @Min and @DecimalMin in Hibernate Validator?

Looking at the Javadocs, they seem to be enforcing the same constra开发者_如何转开发int.


If you take a look at the reference documentation, you'll see that the @Min & @Max annotations both have an impact on the Hibernate metadata while @DecimalMin & @DecimalMax don't. Namely, they add check constraints (which effectively improves your relational mapping).

Also @Max & @Min accept a long value, while @DecimalMax & @DecimalMin accept the String representation of a BigDecimal (which makes these the only possible choice if you're dealing with big numbers that exceed Long.MAX_VALUE or are under Long.MIN_VALUE.

0

精彩评论

暂无评论...
验证码 换一张
取 消