gpt4 book ai didi

java - 通过注解使用 Hibernate UUIDGenerator

转载 作者:IT老高 更新时间:2023-10-28 13:51:53 26 4
gpt4 key购买 nike

我正在使用我的 uuid,如下所示:

@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(name = "uuid", unique = true)
private String uuid;

但我收到了智能 hibernate 警告:

Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead

所以我想切换到 org.hibernate.id.UUIDGenerator,现在我的问题是我应该如何告诉 Hibernate 的生成器。我看到有人将它用作“hibernate-uuid” - 所以这是我尝试过的,但结果是否定的:

@Id
@GeneratedValue(generator = "hibernate-uuid")
@GenericGenerator(name = "hibernate-uuid", strategy = "hibernate-uuid")
@Column(name = "uuid", unique = true)
private String uuid;

最佳答案

应该是uuid2:

...
@GenericGenerator(name = "uuid", strategy = "uuid2")
...

5.1.2.2.1. Various additional generators .

关于java - 通过注解使用 Hibernate UUIDGenerator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6356834/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com