hibernate 定义枚举的列类型

uurity8g  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(212)

在从6.1.7升级到6.2.0时,我在模式验证过程中得到以下错误消息:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [receiving_status] in table [buddies_anonymized]; found [int (Types#INTEGER)], but expecting [tinyint (Types#TINYINT)]

字符串
完整的类BuddyAnonymized可以在here中找到。属性receivingStatus的声明如下(没有应用注解):

private Status receivingStatus = Status.NOT_REQUESTED;


Status类型是一个枚举,定义如下:

public enum Status
{
    NOT_REQUESTED, REQUESTED, ACCEPTED, REJECTED
}


这个问题我在Hibernate项目上报告为HHH-16422。由于我还没有得到回应,我想实现一个解决方案,并显式定义列类型,如下所示:

@Column(columnDefinition = "INTEGER")
    private Status receivingStatus = Status.NOT_REQUESTED;


但是,仍然报告了相同的错误。这里发生了什么问题?

wf82jlnq

wf82jlnq1#

use columnDefinition =“int”:

@Column(columnDefinition = "int")
private Status receivingStatus = Status.NOT_REQUESTED;

字符串
这对我很有效

相关问题