Bean Validation constraints are not honored by Persistence#generateSchema()

Description

When generating a DB schema via Persistence#generateSchema(), Bean Validation constraints are not considered when creating the create DDL statements. BeanValidationIntegrator#integrate() is never called in that case, hence TypeSafeActivator isn't invoked either, which would amend the DDL based on constraints such as @NotNull, @Size etc.

If I bootstrap an EMF and e.g. trigger schema generation via javax.persistence.schema-generation.scripts.action the constraints show up in the emitted DDL as expected.

Environment

None

Activity

Show:
kostd
February 5, 2018, 2:33 PM

stumbled on this issue too, 5.1.10 also affected
trying to migrate to Wildfly 11.0.0.Final (Hibernate 5.1.10,Final) from 10.0.1.Final(hibernate 5.0.10.Final)

have entity with some not null columns:

this is dml generated by 5.1.10.Final:

only id field has notnull-modifier

this is dml generated by 5.0.10.Final:

all @NotNull-fields have notnull-modifier

Michael Düsterhus
February 28, 2018, 2:46 PM

I also experience this issue when switching from Hibernate 5.0 to 5.1
I also added javax.el dependency for validator, but this doesn't fix it.

Tom Pischke
January 15, 2019, 1:22 PM
Edited

Same regression here, except I am calling org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl#generateSchema. Pretty surprised there isn't any progress on this major issue.

Assignee

Unassigned

Reporter

Gunnar Morling

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.0.10

Affects versions

Priority

Major
Configure