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

假如想象 提交于 2019-12-08 16:10:09

问题


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 constraint.


回答1:


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.



来源:https://stackoverflow.com/questions/5129825/difference-between-max-and-decimalmax-and-min-and-decimalmin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!