Class UlidConverter

  • All Implemented Interfaces:
    javax.persistence.AttributeConverter<String,​byte[]>

    public class UlidConverter
    extends Object
    implements javax.persistence.AttributeConverter<String,​byte[]>
    Serves to convert the string ULID representation of the field in the Java entity class into the byte array representation for storage in a binary field in the database. This can serve to save some memory space in the database (especially for indexed fields) at the cost of readability and easy data troubleshooting. There is a string passthrough version of this converter as well. Which version is used is determined by which library is mounted on the classpath at runtime.

    String fields in an entity class that should receive this persistence behaviour should be annotated with @Convert(converter = UlidConverter.class).

    Author:
    Jeff Fischer
    • Constructor Detail

      • UlidConverter

        public UlidConverter()
    • Method Detail

      • convertToDatabaseColumn

        public byte[] convertToDatabaseColumn​(String attribute)
        Specified by:
        convertToDatabaseColumn in interface javax.persistence.AttributeConverter<String,​byte[]>
      • convertToEntityAttribute

        public String convertToEntityAttribute​(byte[] dbData)
        Specified by:
        convertToEntityAttribute in interface javax.persistence.AttributeConverter<String,​byte[]>