springhibernate

Set "text" as default type for string in JPA?


I use Spring Boot + Spring Data + Postgresql + Kotlin in my project.

By default, JPA use varchar(255) for string fields, so I need add for all my string column @Column(columnDefinition = "TEXT").

There are any way to set TEXT for String by default when I don't add @Column?


Solution

  • Currently there is no way to do this.

    You have to either use @Lob or @Column(columnDefinition="TEXT").

    More info here - https://www.baeldung.com/jpa-annotation-postgresql-text-type