Hey,
i recently created a Issue at the Spring Boot JPA repository on Github to explain a problem i encountered while upgrading from Spring Boot 2.x to 3.0.x over to 3.1.x and it seems to be a problem within Hibernate.
Im using the ddl-generation provided by Hibernate through Spring Boot.
For the Migration from Spring Boot 2.x. to 3.0.x i had to modify my Entities as following:
@Getter
@Setter
@Entity
public class Entity1 {
@Id
@Type(type = "uuid-char")
private UUID id;
private String field1;
private String field2;
private String field3;
}
@Getter
@Setter
@Entity
public class Entity1 {
@Id
- @Type(type = "uuid-char")
+ @JdbcTypeCode(SqlTypes.VARCHAR)
private UUID id;
private String field1;
private String field2;
private String field3;
}
The generated DDL-SQL already differs for those definitions between SB 2 and SB 3 like this:
Spring Boot 2.7.x:
create table entity1 (id varchar(255) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), primary key (id)) engine=InnoDB;
Spring Boot 3.x:
create table entity1 (id varchar(36) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), primary key (id)) engine=InnoDB;
Booting up the Spring Boot 3.0.x application had no impact on the database (im using update-mode) and the application booted up without any problems.
After upgrading to Spring Boot 3.1.x (which uses Hibernate 6.2 over Hibernate 6.1) the update-mode tries to modify (ALTER TABLE) all IDs with a smaller VARCHAR-datatype which fails due to some constraints.
I’d like to setup hibernate to ignore datatype lengths like it did with Spring Boot 3.0.x but i dont know how
Spring Issue for ref: DDL generations differs between Spring Boot 3.0.x and 3.1.x when using UUID · Issue #3087 · spring-projects/spring-data-jpa · GitHub
Kings regards
SeaLife