New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@NotNull on JPA entity not respected in schema generation #31726
Comments
Spring is not responsible for the generation of the schema, this is a hibernate feature. Downgrading your sample to use
Please reach out to the Hibernate community if you need help. |
Thanks for your reply @bclozel. I can not reproduce what you see. I created a branch combining hibernate
Updating only hibernate to |
You should not upgrade to spring-orm 6.1.1, as this leads to an invalid combination of dependencies. Spring Boot 3.1.x depends on Spring Framework 6.0.x: your application ends of with a mix of Spring Framework 6.0.x and 6.1.x versions. Just using Spring Boot 3.1.5 dependency management and downgrading to Hibernate |
Spring boot 3.1.5 does work without any changes to the hibernate version suggested by the spring boot plugin. |
Reopening to further check for posssible regressions. |
So that processing reacts to the If some other code checks |
In this case the validation provider is present - with Spring Boot 3.1.5 I'm seeing |
Maybe DDL generation only checks for If this remains unsolvable on the DDL side, we can also roll back our change. It was just meant to help for error reporting when the validation provider setup is incomplete. |
spring-orm
6.1.0 / 6.1.1: jakarta.validation.constraints.NotNull
not respected for DDL
spring-orm
6.1.0 / 6.1.1: jakarta.validation.constraints.NotNull
not respected for DDLspring-orm
6.1: jakarta.validation.constraints.NotNull
not respected for DDL
spring-orm
6.1: jakarta.validation.constraints.NotNull
not respected for DDL
I looked into this a bit more and found that bean validation constraints are not applied at all to the generated schema if the I have found an issue that suggests that as well as other cleanup tasks related to this validation mode support: https://hibernate.atlassian.net/browse/HHH-12287 In light of that, I will revert #30549 and add a note about this Hibernate issue to prevent further changes on our side. |
Is the fix released? I have this problem with Spring 6.1.4 (Spring Boot 3.2.3) |
@jordanms yes this has been released with 6.1.2. You can create a new issue in this issue tracker if you manage to reproduce the problem with a minimal application (please attach this app as a zip to the issue or share the git repository URL). |
Affects: spring-orm 6.1.0 / 6.1.1:
During a spring boot update (3.1.5 to 3.2), I noticed that fields in entities that are annotated as
jakarta.validation.constraints.NotNull
no longer lead to the correct DDL statements.Example:
should trigger ddl statement that contains the not null constraint for the name attribute:
but it does generate the following ddl statement without the not null constraint for the name attribute:
Note that
@Column(nullable = false)
does still work. Only@NotNull
does not.I was able to boil it down to the spring-orm update from 6.0.13 to 6.1.0 (which happens when updating spring boot as mentioned above).
Please see the following git project where I reproduced the issue: https://github.com/cowclaw/spring-orm-problem-demo
The commits tell the whole story:
Included is a test that fails when the DDL statement does not meet the expectations.
Thanks for the great job you do on spring framework and thanks for having a look into the issue! 😄
The text was updated successfully, but these errors were encountered: