Skip to content

Hibernate unnecessarily executes ALTER TABLE on TEXT columns in PostgreSQL at every application startup #3782

@Gyeom

Description

@Gyeom

🐛 Bug Description

When using Spring Data JPA with @column(columnDefinition = "TEXT"), Hibernate executes an unnecessary ALTER TABLE statement every time the application starts.

In PostgreSQL, if a column is already of type TEXT, Hibernate should not alter its type repeatedly. However, it keeps executing:

ALTER TABLE example.tbl_product ALTER COLUMN description SET DATA TYPE TEXT;

This behavior is problematic because it introduces unnecessary schema modifications, increases startup time, and might impact performance.

🎯 Expected Behavior

  • If the column is already of type TEXT, Hibernate should not execute ALTER TABLE again.
  • Schema validation should detect that the column type is unchanged and avoid unnecessary DDL statements.

1️⃣ Entity Code

    @Column(columnDefinition = "TEXT")
    var description: String

2️⃣ application.yml Configuration

spring:
  jpa:
    hibernate:
      ddl-auto: update

🛠 Environment Details

Spring Boot : 3.3.4
Spring Data JPA : 3.3.4
Hibernate : 6.5.3.Final

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions