I often specify my @Column
annotations like this:
@Column(columnDefinition="character varying (100) not null",length=100,nullable=false)
As you can see I specify length
and nullable
even though the columnDefinition
already specifies those. That's because I don't know where/when these values are used exactly.
So, when specifying columnDefinition
, what other properties of @Column
are made redundant?
If it matters, I use Hibernate and PostgreSQL
columnDefinition will override the sql DDL generated by hibernate for this particular column, it is non portable and depends on what database you are using. You can use it to specify nullable, length, precision, scale... ect.
Source: Stackoverflow.com