问题描述
@Max
和 @DecimalMax
和 @Min
code>和 @DecimalMin
在Hibernate Validator中?
看着Javadocs,他们似乎在执行如果你看看,您会看到@Min& @Max注释对Hibernate元数据都有影响,而@DecimalMin& @DecimalMax不要。也就是说,他们添加了检查约束(这有效地改善了你的关系映射)。
也@Max& @Min接受一个很长的值,而@DecimalMax& @DecimalMin接受BigDecimal的字符串表示形式(如果您处理的数字超过Long.MAX_VALUE或Long.MIN_VALUE以下,则这是唯一可能的选择。)
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.
解决方案 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.
这篇关于@Max和@DecimalMax之间的区别(以及@Min和@DecimalMin)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!