Class DalUUIDGenerator

  • All Implemented Interfaces:
    org.hibernate.id.Configurable, org.hibernate.id.IdentifierGenerator

    public class DalUUIDGenerator
    extends org.hibernate.id.UUIDGenerator
    Extends the standard Hibernate UUIDGenerator. This is needed because:
    • the standard Hibernate UUIDGenerator will overwrite the id even if the object already has one. The goal is to try to keep an id if it has been assigned to an object. This is important in case of imports.
    • the standard uuidgenerator will generate uuid strings of length 36 with the - as a separator, the length should be 32
    Author:
    mtaal
    • Field Summary

      • Fields inherited from class org.hibernate.id.UUIDGenerator

        UUID_GEN_STRATEGY, UUID_GEN_STRATEGY_CLASS
      • Fields inherited from interface org.hibernate.id.IdentifierGenerator

        ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
    • Constructor Detail

      • DalUUIDGenerator

        public DalUUIDGenerator()
    • Method Detail

      • generate

        public Serializable generate​(org.hibernate.engine.spi.SharedSessionContractImplementor session,
                                     Object obj)
                              throws org.hibernate.HibernateException
        Specified by:
        generate in interface org.hibernate.id.IdentifierGenerator
        Overrides:
        generate in class org.hibernate.id.UUIDGenerator
        Throws:
        org.hibernate.HibernateException