Reputation: 235
I try to understand which annotation for hibernate field have highest precedence. I use @Column, @Length and @Size for the same field and want to know which value will be taken to set column length in a database.
@Column(name = "var", length = 5)
@Length(max = 167)
@Size(max = 64)
private String var;
Using above code, column length in database is set to 167.
'Hibernate: create table test (id int4 not null, var varchar(167), primary key (id))'
@Column(name = "var", length = 5)
@Length(max = 168)
@Size(max = 64)
private String var;
But if I use this code I got column length equals to 64.
'Hibernate: create table test (id int4 not null, var varchar(64), primary key (id))'
Could you help me understand this? Do you know any reference which completely describe meaning of @Column, @Length and @Size annotation?
Upvotes: 0
Views: 869