4

I'm using hiberate 4.3.5 Final and encounter following warning

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

So i have change my mapping file unique id generator from

generator class="uuid.hex"

to

generator class="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?

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

1 Answer 1

6

The missing "-" is the exact difference.

As the documentation of UUIDHexGenerator says:

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

And also:

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.

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

Sign up to request clarification or add additional context in comments.

2 Comments

I did not configure to have a separator in UUID2 . Is it configurable to remove the "-". Or the "-" is in place to IETF RFC 4122 standard?
@viknesh The "-" are required for a valid UUID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.