Hibernate 的类型注释不起作用

Nis*_*rat 1 spring hibernate jpa nhibernate-mapping spring-boot

我想使用 @Type 注释将 UUID 值从字节转换为字符串: @Type(type="uuid-char")但我收到错误:注释类型 Type 的属性类型未定义。

进口:import org.hibernate.annotations.Type; 代码:

    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator")
    @Column(name = "id", columnDefinition = "VARCHAR(40)")
    @Type(type="uuid-char")
    @JsonIgnore
    private UUID id;
Run Code Online (Sandbox Code Playgroud)

我还在这里搜索了它https://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e2794但它具有与我使用的相同的语法。我缺少什么?

mas*_*007 5

尝试使用@JdbcTypeCode(SqlTypes.VARCHAR)替代。

更新到 Spring Boot 3.0.0 后,我们遇到了同样的问题。代替使用@JdbcTypeCode(SqlTypes.VARCHAR)。我用PSQL试了一下。