가자공부하러!

Hibernate에서 uuid와 uuid2의 차이점(스크랩) 본문

공부/Java

Hibernate에서 uuid와 uuid2의 차이점(스크랩)

오피스엑소더스 2020. 6. 16. 11:09

원문 : https://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/mapping.html#d0e5294

 

결론 : uuid는 RFC 4122 호환안됨 -> warn로그 쌓임

또다른 이유가 있을듯함

 

uuid

Generates a 128-bit UUID based on a custom algorithm. The value generated is represented as a string of 32 hexidecimal 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. If you need RFC 4122 compliant UUIDs, consider using "uuid2" generator discussed below.

 

 

uuid2

Generates a IETF RFC 4122 compliant (variant 2) 128-bit UUID. The exact "version" (the RFC term) generated depends on the pluggable "generation strategy" used (see below). Capable of generating values as java.util.UUID, java.lang.String or as a byte array of length 16 (byte[16]). The "generation strategy" is defined by the interface org.hibernate.id.UUIDGenerationStrategy. The generator defines 2 configuration parameters for defining which generation strategy to use:

uuid_gen_strategy_class

Names the UUIDGenerationStrategy class to use

uuid_gen_strategy

Names the UUIDGenerationStrategy instance to use

Out of the box, comes with the following strategies:

  • org.hibernate.id.uuid.StandardRandomStrategy (the default) - generates "version 3" (aka, "random") UUID values via the randomUUID method of java.util.UUID

  • org.hibernate.id.uuid.CustomVersionOneStrategy - generates "version 1" UUID values, using IP address since mac address not available. If you need mac address to be used, consider leveraging one of the existing third party UUID generators which sniff out mac address and integrating it via the org.hibernate.id.UUIDGenerationStrategy contract. Two such libraries known at time of this writing include http://johannburkard.de/software/uuid/ and http://commons.apache.org/sandbox/id/uuid.html

 

Comments