
ussually the hexadecimal value which generated.

as we know that UUID in Hibernate generate hexadecimal 16bytes. Then through Base64 transcoding, we can get the UUID we want. i have a little question about UUID Hibernate. You can use getLeastSignificantBits and getMostSignificantBits in to obtain two longs (64-bit) respectively.
Hibernate uuid generator generator#
The 128-bit UUID is represented as two long data in Java. The values this generator can return include UUID, String and byte16. Since the UUID standard data is 128-bit in total, we can re-encode this 128-bit with Base64. In the case of the same length of digits, it represents more content than the hexadecimal system. Base64 is equivalent to using the 64 hexadecimal system to represent the data. That's why the name of Base64 comes from. Based on the specification, the UUID should be created with the MAC address and a timestamp. Hibernate framework provides many built-in generator classes: assigned increment sequence hilo native identity seqhilo uuid guid select foreign. Since the characters used in Base64 encoding include 26 uppercase and lowercase letters, plus 10 numbers, plus "+" and slash "/", a total of 64 characters. Hibernate can also generate a UUID based on IETF RFC 4122 version 1.

For example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6 b, Hibernate UUIDĬompared with the RFC 4122 standard, the UUID generated by Hibernate by default is shorter (32 characters) without the useless "-" separator. The UUID in Java adopts the RFC 4122 standard, and is expressed in hexadecimal according to the standard data (36 characters). I think it is more meaningful to share with everyone.

When I checked the company's project, I found a better way to generate UUID, which is to Base64 the UUID data. Since Hibernate's UUID needs to occupy 32-bit characters, it will generally make people feel efficient and increase storage usage. When using Hibernate for object mapping, I always use UUID as the primary key.
