Java Hibernate设置最小和最大列长度

时间:2015-02-06 01:00:27

标签: java hibernate annotations

我需要知道如何在hibernate中为列设置min或max注释。

@Column (name = "password", 'min = 6, max = 16') // something like this
    private String password;

1 个答案:

答案 0 :(得分:3)

尝试@Size约束

@Size(min = 6, max = 16)

请参阅Hibernate文档中的示例1.3 https://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html/validator-gettingstarted.html