Class UuidV1RndIdGenerator

java.lang.Object
io.ebeaninternal.server.idgen.UuidV1RndIdGenerator
All Implemented Interfaces:
PlatformIdGenerator
Direct Known Subclasses:
UuidV1IdGenerator

public class UuidV1RndIdGenerator extends Object implements PlatformIdGenerator
IdGenerator for (pseudo) type 1 UUIDs.

This implementation generates a type 1 UUID according to https://tools.ietf.org/html/rfc4122.html#section-4.2 but has no persistence storage. It generates a new random 47 bit node ID with every UUID.

Use this, if you want randomness in your UUIDs but want to take advantage of index optimizations of the database. It may be good with AUTO_BINARY_OPTIMIZED and MySql.

See: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/

  • Field Details

  • Constructor Details

    • UuidV1RndIdGenerator

      public UuidV1RndIdGenerator()
  • Method Details

    • computeNanoOffset

      protected void computeNanoOffset()
      Computes the internal offset between System.nanoTime() and System.currentTimeMillis().
    • saveState

      protected void saveState()
      Method to overwrite to save the state in a non volatile place.
    • getNodeIdBytes

      protected byte[] getNodeIdBytes()
      returns a random 47 bit value according to https://tools.ietf.org/html/rfc4122.html#section-4.5
    • nextId

      public UUID nextId(Transaction t)
      Return UUID from UUID.randomUUID();
      Specified by:
      nextId in interface PlatformIdGenerator
    • getName

      public String getName()
      Returns "uuid".
      Specified by:
      getName in interface PlatformIdGenerator
    • isDbSequence

      public boolean isDbSequence()
      Returns false.
      Specified by:
      isDbSequence in interface PlatformIdGenerator
    • preAllocateIds

      public void preAllocateIds(int allocateSize)
      Ignored for UUID as not required as a performance optimisation.
      Specified by:
      preAllocateIds in interface PlatformIdGenerator