在.hbm.xml中定义字段的描述
<property name="name" type="string">
<column name="name" length="20" not-null="true">
<comment>用户姓名</comment>
</column>
</property>
这样,根据此映射文件生成的表结构ddl语句中就会产生这样的字段定义:
create table users
(
...
name varchar(20) not null comment '用户姓名',
...
);
目前Hibernate Annotation还没有提供定义字段描述的功能
with hbm2ddl and hbm2doc its a shame that Annotation does not support setting a comment on table and columns.
补充一下JPA注解定义方式:
@Column(unique = true, nullable = false, length = 50,columnDefinition = "comment '用户姓名'" )