Setting column length of a Long value with JPA annotations

Posted by Gearóid on Stack Overflow See other posts from Stack Overflow or by Gearóid
Published on 2010-04-08T14:00:11Z Indexed on 2010/04/08 14:03 UTC
Read the original article Hit count: 342

Filed under:
|
|

Hi,

I'm performing a little database optimisation at the moment and would like to set the column lengths in my table through JPA. So far I have no problem setting the String (varchar) lengths using JPA as follows:

@Column(unique=true, nullable=false, length=99) 
public String getEmail() {
    return email;
}

However, when I want to do the same for a column which is of type Long (bigint), it doesn't work. For example, if I write:

@Id
@Column(length=7)
@GeneratedValue(strategy = GenerationType.AUTO) 
public Long getId() {
    return id;
}

The column size is still set as the default of 20. Are we able to set these lengths in JPA or am I barking up the wrong tree?

Thanks, Gearoid.

© Stack Overflow or respective owner

Related posts about jpa

Related posts about annotations