Top Description Fields Constructors Methods
org.hibernate.id.uuid

public Class CustomVersionOneStrategy

extends Object
implements UUIDGenerationStrategy
Class Inheritance
All Implemented Interfaces
org.hibernate.id.UUIDGenerationStrategy, java.io.Serializable
Imports
java.util.UUID, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.id.UUIDGenerationStrategy, org.hibernate.internal.build.AllowSysOut, org.hibernate.internal.util.BytesHelper

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 legacy org.hibernate.id.UUIDHexGenerator id generator but uses a RFC 4122 compliant layout (variant 2).

NOTE : Can be a bottle neck due to the need to synchronize in order to increment an internal count as part of the algorithm.

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static long
public UUID
generateUUID(SharedSessionContractImplementor
The session asking for the generation
session
)

Implements org.hibernate.id.UUIDGenerationStrategy.generateUUID.

Generate the UUID.
public int
getGeneratedVersion()

Implements org.hibernate.id.UUIDGenerationStrategy.getGeneratedVersion.

Which variant, according to IETF RFC 4122, of UUID does this strategy generate?
public long
public static void
main(String[] args)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mostSignificantBitsback to summary
private final long mostSignificantBits

Constructor Detail

CustomVersionOneStrategyback to summary
public CustomVersionOneStrategy()

Method Detail

generateLeastSignificantBitsback to summary
public static long generateLeastSignificantBits(long seed)
generateUUIDback to summary
public UUID generateUUID(SharedSessionContractImplementor session)

Implements org.hibernate.id.UUIDGenerationStrategy.generateUUID.

Doc from org.hibernate.id.UUIDGenerationStrategy.generateUUID.

Generate the UUID.

Parameters
session:SharedSessionContractImplementor

The session asking for the generation

Returns:UUID

The generated UUID.

Annotations
@Override
getGeneratedVersionback to summary
public int getGeneratedVersion()

Implements org.hibernate.id.UUIDGenerationStrategy.getGeneratedVersion.

Doc from org.hibernate.id.UUIDGenerationStrategy.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)
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.

Returns:int

The supported generation version

Annotations
@Override
getMostSignificantBitsback to summary
public long getMostSignificantBits()
mainback to summary
public static void main(String[] args)
Annotations
@AllowSysOut