Class UniqueIdentifierGenerator

java.lang.Object
org.openremote.container.util.UniqueIdentifierGenerator
All Implemented Interfaces:
org.hibernate.boot.model.relational.ExportableProducer, org.hibernate.id.Configurable, org.hibernate.id.IdentifierGenerator

public class UniqueIdentifierGenerator extends Object implements org.hibernate.id.IdentifierGenerator
Generate a globally unique identifier value.

This is a Hibernate identifier generator as well: Assigns a random UUID if the persisted entity instance is of type IdentifiableEntity and if its IdentifiableEntity.getId() method returns null.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final com.fasterxml.uuid.impl.NameBasedGenerator
     
    protected static final com.fasterxml.uuid.impl.RandomBasedGenerator
     

    Fields inherited from interface org.hibernate.id.IdentifierGenerator

    ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    generate(org.hibernate.engine.spi.SharedSessionContractImplementor session, Object object)
     
    static String
    Generates a random UUID value encoded as Base62, 22 characters long.
    static String
    generateId(byte[] bytes)
    Generates the same UUID value encoded as Base62, 22 characters long, if the bytes are the same.
    static String
    Generates the same UUID value encoded as Base62, 22 characters long, if the name is the same.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.hibernate.id.IdentifierGenerator

    configure, initialize, registerExportables, supportsJdbcBatchInserts
  • Field Details

    • randomGenerator

      protected static final com.fasterxml.uuid.impl.RandomBasedGenerator randomGenerator
    • nameGenerator

      protected static final com.fasterxml.uuid.impl.NameBasedGenerator nameGenerator
  • Constructor Details

    • UniqueIdentifierGenerator

      public UniqueIdentifierGenerator()
  • Method Details

    • generate

      public Serializable generate(org.hibernate.engine.spi.SharedSessionContractImplementor session, Object object) throws org.hibernate.HibernateException
      Specified by:
      generate in interface org.hibernate.id.IdentifierGenerator
      Throws:
      org.hibernate.HibernateException
    • generateId

      public static String generateId()
      Generates a random UUID value encoded as Base62, 22 characters long.
    • generateId

      public static String generateId(String name)
      Generates the same UUID value encoded as Base62, 22 characters long, if the name is the same.
    • generateId

      public static String generateId(byte[] bytes)
      Generates the same UUID value encoded as Base62, 22 characters long, if the bytes are the same.