質問

I'm on a project with Spring and hibernate, in the debugging phase. There are two entities that have their tables created automatically by hbm2ddl. This mostly works fine, but the schema indicates that all columns, except for the primary id, allow null. I would like to tell hbm2ddl to create some of these columns disallowing null values. How could this be achieved?

役に立ちましたか?

解決

You need to specify those constraints in your mapping, whether hbm files or annotations.

For hbm files :

<property type="string" name="label" column="M_LABEL" not-null="true"/>

For annotations :

@Column(name = "M_LABEL", nullable = false)
private String label;
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top