Class SimpleJsonbConverter

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

    public class SimpleJsonbConverter
    extends java.lang.Object
    implements javax.persistence.AttributeConverter<java.util.Map<java.lang.String,​java.lang.String>,​java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String convertToDatabaseColumn​(java.util.Map<java.lang.String,​java.lang.String> attribute)  
      java.util.Map<java.lang.String,​java.lang.String> convertToEntityAttribute​(java.lang.String dbData)  
      • Methods inherited from class java.lang.Object

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

      • SimpleJsonbConverter

        public SimpleJsonbConverter()
    • Method Detail

      • convertToDatabaseColumn

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

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