Description
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:
@Entity
public class TestEntity {
@Id
private Long id;
@NotNull
private String name;
}
should trigger ddl statement that contains the not null constraint for the name attribute:
create table test_entity (
id bigint not null,
name varchar(255) not null,
primary key (id)
);
but it does generate the following ddl statement without the not null constraint for the name attribute:
create table test_entity (
id bigint not null,
name varchar(255),
primary key (id)
);
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:
- Show it works on spring boot 3.1.5
- Show it is broken on spring boot 3.2.0
- revert to spring boot 3.1.5
- Show its broken when selectively updating spring-orm
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! 😄