Class UlidConverter

java.lang.Object
com.broadleafcommerce.data.tracking.jpa.UlidConverter
All Implemented Interfaces:
javax.persistence.AttributeConverter<String,String>

public class UlidConverter extends Object implements javax.persistence.AttributeConverter<String,String>
Serves to pass through the string ULID representation of the field in the Java entity class into a varchar field in the database. This is the most readable option and serves as the easiest option during data troubleshooting. However, the Base32 string representation does use more memory to store the value in the database, which can be important when considering database index size. There is a byte array converting version of this class 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
  • Field Details

  • Constructor Details

    • UlidConverter

      public UlidConverter()
  • Method Details

    • getInstance

      public static UlidConverter getInstance()
    • convertToDatabaseColumn

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

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