Class PropertyValueConverter

  • All Implemented Interfaces:
    javax.persistence.AttributeConverter<java.lang.Object,​java.lang.String>

    public class PropertyValueConverter
    extends java.lang.Object
    implements javax.persistence.AttributeConverter<java.lang.Object,​java.lang.String>
    This converter can be used for the values of the type Map.

    The values of the map will be converted to strings to persist them in a string column in the database. A string value coming from the database will be converted to the best matching Java type.

    Currently String, Long, Double and Boolean values are supported.

    Author:
    Nils Bühner
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String convertToDatabaseColumn​(java.lang.Object attribute)
      Converts an arbitrary object to it's string representation, that will be stored in the database.
      java.lang.Object convertToEntityAttribute​(java.lang.String dbData)
      Converts a string value from the database to the best matching java primitive type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertyValueConverter

        public PropertyValueConverter()
    • Method Detail

      • convertToDatabaseColumn

        public java.lang.String convertToDatabaseColumn​(java.lang.Object attribute)
        Converts an arbitrary object to it's string representation, that will be stored in the database.
        Specified by:
        convertToDatabaseColumn in interface javax.persistence.AttributeConverter<java.lang.Object,​java.lang.String>
      • convertToEntityAttribute

        public java.lang.Object convertToEntityAttribute​(java.lang.String dbData)
        Converts a string value from the database to the best matching java primitive type.
        Specified by:
        convertToEntityAttribute in interface javax.persistence.AttributeConverter<java.lang.Object,​java.lang.String>