5

I'm using spring boot and jpa and I have an existing table with attribute as VARCHAR 255:

@Column(name = "description")
private String description;

I tried to change it to longtext with no success:

@Column(name = "description", columnDefinition = "longtext")
private String description;

My configuration in the application.properties file regarding Hibernate ddl is set to update:

spring.jpa.hibernate.ddl-auto = update

Is it possible to change VARCAR 255 to longtext? if it does, How do I do it?

Thanks, Avi

Avi Elgal
  • 149
  • 1
  • 3
  • 9
  • As far I know you have to do it manually by mySQL workbench or something else. Property type are not changed if it is defined once. So do it manually! – Avijit Barua Aug 11 '19 at 12:41

3 Answers3

3
spring.jpa.hibernate.ddl-auto=update

will not do following changes

  • Delete a column which is no longer in entity
  • Modify existing column.

Refer here for more details

MyTwoCents
  • 7,284
  • 3
  • 24
  • 52
1

spring-data-jpa ddl ‘update’ will not change exist colums,neither update nor delete.

steven.tong
  • 345
  • 3
  • 16
1

I also faced the same issue Your current configuration won't update

The best way to do this is through migrations using flyway Documentation : https://flywaydb.org/documentation/

you can write sql queries in your project and alter the same column in your entity.