我使用我的uuid如下:
@Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid") @Column(name = "uuid", unique = true) private String uuid;
但是我收到了一个聪明的Hibernate警告:
使用org.hibernate.id.UUIDHexGenerator不会生成符合IETF RFC 4122的UUID值;考虑改用org.hibernate.id.UUIDGenerator
所以我想切换到org.hibernate.id.UUIDGenerator,现在我的问题是如何将其告知Hibernate的生成器。我看到有人用它作为“hibernateuuid”-这是我尝试过的方法,但结果是负面的:
org.hibernate.id.UUIDGenerator
@Id @GeneratedValue(generator = "hibernate-uuid") @GenericGenerator(name = "hibernate-uuid", strategy = "hibernate-uuid") @Column(name = "uuid", unique = true) private String uuid;
应该是uuid2:
uuid2
... @GenericGenerator(name = "uuid", strategy = "uuid2") ...
参见5.1.2.2.1。各种附加发电机。