简体   繁体   中英

Stop Hibernate from creating not-null constraints

有没有办法阻止Hibernate为使用hbm2ddl = create时使用@javax.validation.constraints.NotNull注释的属性创建非空约束?

From the documentation of Hibernate Validator:

6.1. Database schema-level validation

Out of the box, Hibernate Annotations (as of Hibernate 3.5.x) will translate the constraints you have defined for your entities into mapping metadata. For example, if a property of your entity is annotated @NotNull , its columns will be declared as not null in the DDL schema generated by Hibernate.

If, for some reason, the feature needs to be disabled, set hibernate.validator.apply_to_ddl to false . See also Table 2.2, “Built-in constraints” .

You can also limit the DDL constraint generation to a subset of the defined constraints by setting the property org.hibernate.validator.group.ddl . The property specifies the comma seperated, fully specified classnames of the groups a constraint has to be part of in order to be considered for DDL schema generation.

For more details about the org.hibernate.validator.group.ddl property, see also the section 4.1.2. Configuration .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM