-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
DDL generations differs between Spring Boot 3.0.x and 3.1.x when using UUID #3087
Comments
Try enforcing the column length by writing @column (length=255) yourself for id. |
Spring Data JPA 3.0.x (Boot 3.0) is on Hibernate 6.1 while Spring Data JPA 3.1+ (Boot 3.1+) is on Hibernate 6.2. Since we don't actually do any data schema creation (this is courtesy of Hibernate), it sounds like either a misconfigured Hibernate/JPA issue or a bug in Hibernate 6.2 altogether. I'd suggest creating a reproducer based purely on Hibernate and submitting an issue with them. To get more info, you can also add the following to your
If you think this is actually a Spring Data issue, please provide a reproducer for the issue including a test case that demonstrates the correct behavior using the EntityManager directly. |
Hey, so i created a new project to verify the issue.. @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 Entity2 {
@Id
@Type(type = "uuid-char")
private UUID id;
@ManyToOne
private Entity1 entity1;
private String field1;
private String field2;
private String field3;
} Which results in the following SQL: create table entity1 (id varchar(255) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), primary key (id)) engine=InnoDB;
create table entity2 (id varchar(255) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), entity1_id varchar(255), primary key (id)) engine=InnoDB;
alter table entity2 add constraint FK133qwgxc648anidh2vf15ojsr foreign key (entity1_id) references entity1 (id); In Spring Boot 3.0.x the generated SQL with a modified Entity Class to use create table entity1 (id varchar(36) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), primary key (id)) engine=InnoDB;
create table entity2 (id varchar(36) not null, field1 varchar(255), field2 varchar(255), field3 varchar(255), entity1_id varchar(36), primary key (id)) engine=InnoDB;
alter table entity2 add constraint FK133qwgxc648anidh2vf15ojsr foreign key (entity1_id) references entity1 (id); Spring Boot 3.0.x does not alter the tables if the type length differs from the entity definition but Spring Boot 3.1.x verifies the length and tries to change them (probably due to some changes in Hibernate?) |
I'm going to close this issue. If you feel there is a Spring Data JPA issue here, feel free to come back and provide additional details. |
Just to let you guys know aswell, i opened up a question thread in the hibernate forum (https://discourse.hibernate.org/t/ddl-generations-differs-between-spring-boot-2-x-and-3-x-when-using-uuid) and they suggested to drop all foreign keys and alter the table afterwards which worked just fine in my usecase. |
Hey,
I've recently updated my application from Spring Boot 3.0.x to 3.1.1 (and today to 3.1.2) and encountered the following issue:
When generating a DDL using the following EntityClass:
The
id
-Column is generated with a VARCHAR(255) on Spring Boot 3.0.x but with aid
-Column of VARCHAR(36) on Spring Boot 3.1.xI tried using
@Column(length = 255)
to force a generation of VARCHAR(255) but the Column-Annotation was simply ignored.Configuration
Stacktrace
The text was updated successfully, but these errors were encountered: