What does the length attribute do when set on the @Column JPA annontation?

Posted by James McMahon on Stack Overflow See other posts from Stack Overflow or by James McMahon
Published on 2010-05-20T15:18:22Z Indexed on 2010/05/20 15:20 UTC
Read the original article Hit count: 190

Filed under:
|
|
|
|

What exactly does setting the length on a column do in JPA?

@Column(name = "middle_name", nullable = false, length = 32)
public String getMiddleName() {
    return this.middleName;
}

I understand that you can use the annotations to generate the database schema based on the entity objects, but does length do any sort of check or truncation when persistence happens, or it solely used for schema creation?

I also realize that JPA can sit on top of various implementations, the implementation I am concerned with in this case, is Hibernate.

© Stack Overflow or respective owner

Related posts about annotations

Related posts about jpa