休眠 UUID.hex 与 UUID2 [英] Hibernate UUID.hex vs UUID2

查看:53
本文介绍了休眠 UUID.hex 与 UUID2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 hiberate 4.3.5 Final 并遇到以下警告

I'm using hiberate 4.3.5 Final and encounter following warning

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

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

所以我从

生成器类="uuid.hex"

generator class="uuid.hex"

生成器类="uuid2"

generator class="uuid2"

明智的编码我知道这只是一个警告,但是使用 uuid2 比使用 uuid.hex 是否还有其他优势.使用 uuid2 或最佳编码实践是更有效的方法还是标准方法?我正在尝试在我的应用程序中进行最佳编码实践.有没有大师可以帮我解决这个问题?

Coding wise i know this is just a warning but is there any other advantage using uuid2 over uuid.hex. Is it more effective way or standard way to use uuid2 or best coding practise? I'm trying to go for best coding practise in my application. Any guru's can help me on this?

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

One additional thing i notice is that uuid2 key is having "-" compare to the uuid.hex. Any disadvantage?

推荐答案

缺少的-"正是区别所在.

The missing "-" is the exact difference.

正如 UUIDHexGenerator 的文档所说:

返回长度为 32 的字符串的 UUIDGenerator,该字符串将仅包含十六进制数字

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

还有:

用户还可以将其配置为使用分隔符(配置参数separator")将十六进制数字分隔为 8{sep}8{sep}4{sep}8{sep}4.请特别注意,这与 8-4-4-4-12 的 IETF RFC 4122 表示不同.

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 必须在某些位置具有这些-"才能有效.

However, a UUID must have these "-" at certain positions to be valid.

这篇关于休眠 UUID.hex 与 UUID2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆