
de.terrestris.shogun2.hibernate.SimpleJsonbConverter Maven / Gradle / Ivy
The newest version!
package de.terrestris.shogun2.hibernate;
import de.terrestris.shogun2.util.json.Shogun2JsonObjectMapper;
import org.apache.logging.log4j.Logger;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static org.apache.logging.log4j.LogManager.getLogger;
/**
* 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.
*/
@Converter(autoApply = true)
public class SimpleJsonbConverter implements AttributeConverter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy