Package org.hibernate.id.uuid
Class CustomVersionOneStrategy
- java.lang.Object
-
- org.hibernate.id.uuid.CustomVersionOneStrategy
-
- All Implemented Interfaces:
Serializable
,UuidValueGenerator
,UUIDGenerationStrategy
public class CustomVersionOneStrategy extends Object implements UUIDGenerationStrategy, UuidValueGenerator
Applies a version 1 (time-based) generation strategy (using ip address rather than mac address) but applies them in a different layout. The strategy is very similar to the legacyUUIDHexGenerator
id generator but uses a RFC 4122 compliant layout (variant 2).- See Also:
- Serialized Form
- Implementation Note:
- Can be a bottleneck due to the need to synchronize in order to increment an internal count as part of the algorithm.
-
-
Constructor Summary
Constructors Constructor Description CustomVersionOneStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static long
generateLeastSignificantBits(long seed)
UUID
generateUuid(SharedSessionContractImplementor session)
Generate the UUID valueUUID
generateUUID(SharedSessionContractImplementor session)
Generate the UUID.int
getGeneratedVersion()
Which variant, according to IETF RFC 4122, of UUID does this strategy generate? RFC 4122 defines 5 variants (though it only describes algorithms to generate 4): 1 = time based 2 = DCE based using POSIX UIDs 3 = name based (md5 hash) 4 = random numbers based 5 = name based (sha-1 hash)long
getMostSignificantBits()
static void
main(String[] args)
-
-
-
Method Detail
-
getGeneratedVersion
public int getGeneratedVersion()
Description copied from interface:UUIDGenerationStrategy
Which variant, according to IETF RFC 4122, of UUID does this strategy generate? RFC 4122 defines 5 variants (though it only describes algorithms to generate 4):- 1 = time based
- 2 = DCE based using POSIX UIDs
- 3 = name based (md5 hash)
- 4 = random numbers based
- 5 = name based (sha-1 hash)
Returning the values above should be reserved to those generators creating variants compliant with the corresponding RFC definition; others can feel free to return other values as they see fit.
Informational only, and not used at this time.
- Specified by:
getGeneratedVersion
in interfaceUUIDGenerationStrategy
- Returns:
- The supported generation version
-
generateUuid
public UUID generateUuid(SharedSessionContractImplementor session)
Description copied from interface:UuidValueGenerator
Generate the UUID value- Specified by:
generateUuid
in interfaceUuidValueGenerator
-
generateUUID
public UUID generateUUID(SharedSessionContractImplementor session)
Description copied from interface:UUIDGenerationStrategy
Generate the UUID.- Specified by:
generateUUID
in interfaceUUIDGenerationStrategy
- Parameters:
session
- The session asking for the generation- Returns:
- The generated UUID.
-
getMostSignificantBits
public long getMostSignificantBits()
-
generateLeastSignificantBits
public static long generateLeastSignificantBits(long seed)
-
main
public static void main(String[] args)
-
-