Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Globally set default 'nullable=false' for @Column definition

From @Column annotation documentation i verified nullable attribute has true as default value.

In my entities definitions I'd like to set columns non-nullable as default behavior, but I don't want to set this for every single column.

Is there a way to globally change default value for nullable attribute (and eventually others)?

like image 577
davioooh Avatar asked Nov 10 '22 11:11

davioooh


1 Answers

JPA takes the nullable property from the tables on your database if the columns on your table were notnull then your entity attributes would be @NotNull too. You could do the changes on your database and recreate the entities.

like image 116
Yumarx Polanco Avatar answered Nov 15 '22 13:11

Yumarx Polanco