Skip to content
Advertisement

JPA @Column annotation to create comment/description

I was wondering is it possible to create from jpa/hibernate annotation a database column description/comment like this:

ALTER TABLE tablename CHANGE status status INT(11) NOT NULL COMMENT 'sample description/comment';

It will be great functionality, but I cant find anything about this in JPA specification.

Maybe I should use @Column(columnDefinition="") property, but I dont have any clue. Please help

Advertisement

Answer

I found answer for my own question.

I am not sure is it ok? Will it work for all Databases?

For sure it works for mysql.

Here is the working code:

@Column(columnDefinition=" INT(11) NOT NULL COMMENT '0 for no action, 1 for executed, 2 for validated, 3 for aproved'")
private int status;
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement