Class PrivilegeValueConverter

java.lang.Object
hu.rts.mike.example.dev.crm.security.PrivilegeValueConverter
All Implemented Interfaces:
jakarta.persistence.AttributeConverter<Privilege,String>

public class PrivilegeValueConverter extends Object implements jakarta.persistence.AttributeConverter<Privilege,String>
Workaround required to make Privileges extendable between Mike Generations. Otherwise, Hibernate would create a database level check what fixes the accepted values of Privilege enum in Roles table. Which is problematic because Hibernate and Spring Data do not update this database level check during DDL schema update process. With this AttributeConverter Hibernate do not create this problematic the database level check.
  • Constructor Details

    • PrivilegeValueConverter

      public PrivilegeValueConverter()
  • Method Details

    • convertToDatabaseColumn

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

      public Privilege convertToEntityAttribute(String data)
      Specified by:
      convertToEntityAttribute in interface jakarta.persistence.AttributeConverter<Privilege,String>