Difference between @Size, @Length and @Column(length=value) when using JPA and Hibernate

  1. @Column is a JPA annotation and the length attribute is used by the schema generation tool to set the associated SQL column length.
  2. @Size is a Bean Validation annotation that validates that the associated String has a value whose length is bounded by the minimum and maximum values.
  3. @Length is a Hibernate-specific annotation and has the same meaning as @Size

So both 2. and 3. should validate the String length using Bean Validation. I’d pick 2. because it’s generic.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)