@Max和@DecimalMax之间的区别(以及@Min和@DecimalMin) [英] Difference between @Max and @DecimalMax (and @Min and @DecimalMin)

查看:24571
本文介绍了@Max和@DecimalMax之间的区别(以及@Min和@DecimalMin)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@Max @DecimalMax @Min

code>和 @DecimalMin 在Hibernate Validator中?



看着Javadocs,他们似乎在执行如果你看看 /hibernate/validator/4.2/reference/en-US/pdf/hibernate_validator_reference.pdf\">参考文档,您会看到@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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆