简体   繁体   中英

Java Hibernate set min and max column length

I need to know how to set the min or max annotation for a column in hibernate.

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

Try @Size constraint

@Size(min = 6, max = 16)

Refer Example 1.3 in Hibernate documentation https://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html/validator-gettingstarted.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM