I have updated recently version of:
- Hibernate to -> 5.6.14.Final
- spring boot to -> 2.7.7
- java to -> 17
And remarked that changes in @Column annotation are not reflected into DB. For example, if I add a column:
@Column(name = "visible_type_test")
private VisibleType visibleTypeTest = VisibleType.VISIBLE;
And then after running the project, decide to add nullable + columnDefinition:
@Column(name = "visible_type_test", columnDefinition = "int DEFAULT 1", nullable = false)
private VisibleType visibleTypeTest = VisibleType.VISIBLE;
The changes are not reflected.
But if I drop the column and run the project again, it is successfully adds all default values (changes are reflected)
Do you know what could be the problem ? In application properties I have this configuration set:
spring.jpa.hibernate.ddl-auto=none
I tried switching to 'ddl-auto to update', but still it did not help.
Tried also to remove@DynamicUpdate
annotation from entity, but also did not help.
Why it was working all this time with the current settings and now it doesn't ? Was there any hibernate updates which I am not aware of ?
Edited: I am already using flyway. My problem is not about updating column name or deleting constraints. My problem is that unique constraints are not being added if I switch a column from nullable=true, to nullable=false. Also Default value is not being added to all existing values with columnDefi ition ... Default. I DID NOT NEEDED TO CREATE FLYWAY MIGRATION BEFORE IN ORDER TO DO THIS CHANGES. THEY WERE HAPPENING AUTOMATICALLY.
Found a similar post here also with no answer provided: Spring boot tables in database not updated when entity field is modified