编程语言
首页 > 编程语言> > java-休眠UUID.hex与UUID2

java-休眠UUID.hex与UUID2

作者:互联网

我正在使用休眠4.3.5最终版本,并遇到以下警告

org.hibernate.id.UUIDHexGenerator警告-HHH000409:使用org.hibernate.id.UUIDHexGenerator不会生成符合IETF RFC 4122的UUID值;考虑改用org.hibernate.id.UUIDGenerator

所以我从更改了我的映射文件唯一ID生成器

生成器类=“ uuid.hex”

生成器类=“ uuid2”

明智地编码,我知道这只是一个警告,但是使用uuid2而不是uuid.hex还有其他好处.使用uuid2或最佳编码实践是更有效的方法还是标准的方法?我正在尝试在我的应用程序中寻求最佳编码实践.任何大师都可以帮助我吗?

我注意到的另一件事是uuid2键与uuid.hex相比具有“-”.有什么缺点吗?

解决方法:

缺少的“-”是确切的区别.

正如UUIDHexGenerator的文档所述:

A UUIDGenerator that returns a string of length 32, This string will consist of only hex digits

并且:

Users can also configure it to use a separator (config parameter “separator”) which separates the hexidecimal digits into 8{sep}8{sep}4{sep}8{sep}4. Note specifically that this is different than the IETF RFC 4122 representation of 8-4-4-4-12.

但是,UUID必须在某些位置具有这些“-”才能有效.

标签:hibernate,uuid,annotations,hibernate-mapping,java
来源: https://codeday.me/bug/20191121/2051443.html