Spring JPA global_quoted_identifiers 错误地引用列类型 TEXT

use*_*825 5 spring-data-jpa

我正在使用 global_quoted_identifiers 属性来处理我正在维护的应用程序中用于列名的保留关键字的问题。然而我刚刚遇到了一个错误,其中正在生成一个创建表语句,如下所示......

create table `MyTable` (`id` bigint not null auto_increment, `body` `TEXT`...
Run Code Online (Sandbox Code Playgroud)

MySQL 中的 create 语句失败,因为不应引用 TEXT。

我不知道为什么会发生这种情况。它不会对其他列类型(bigint、varchar 等)执行此操作。

为了让 JPA 正确处理 MySQL TEXT 列类型,我还需要做其他事情吗?

更新:这是演示问题的数据类......

@Entity
data class MyTable(
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    val id: Long? = null,

    @Column(columnDefinition = "TEXT")
    var body: String? = null
)
Run Code Online (Sandbox Code Playgroud)

当启用global_quoted_identifiers时,这将导致上面的表创建SQL。

小智 9

你可以尝试使用下面的配置吗?

hibernate.globally_quoted_identifiers = true hibernate.globally_quoted_identifiers_skip_column_definitions = true