Why should I specify @Column( nullable = false )?

前端 未结 3 877
旧时难觅i
旧时难觅i 2020-12-13 17:09

I have an entity annotated with @Entity.
If I am responsible for creating the CREATE TABLE scripts why should I specify @Column( nullable

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 17:50

    In your case there might not be actual benefit, but:

    • if you are using your jpa provider to generate your schema (either via maven or via automatic generation like hbm2ddl.auto), then it matters
    • if you configure your jpa provider to validate the schema against the entity model, then you need them to be in sync.

提交回复
热议问题