Class SimpleJsonbConverter

  • All Implemented Interfaces:
    javax.persistence.AttributeConverter<Map<String,​String>,​String>

    public class SimpleJsonbConverter
    extends Object
    implements javax.persistence.AttributeConverter<Map<String,​String>,​String>
    A JPA converter that can be used to convert jsonb fields into a map. Currently only works with 'simple' json content (only one level objects like {"name": "peter", "someprop": 345}).

    Please note that you'll need to switch to pgjdbc-ng from https://github.com/impossibl/pgjdbc-ng instead of using the standard postgres driver.

    Please also note that if you want optimal performance you'll need to add an index manually, hibernate can only create btree indexes.

    • Constructor Detail

      • SimpleJsonbConverter

        public SimpleJsonbConverter()
    • Method Detail

      • convertToDatabaseColumn

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

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