Answer the question
In order to leave comments, you need to log in
JSONB in Hibernate?
You need to make Hibernate friends with PostgreSQL, I do it as follows:
Define your UserType
public class JSONType implements UserType {
@Override
public int[] sqlTypes() {
return new int[]{Types.JAVA_OBJECT};
}
@Override
public Class<JSONObject/*MyJson*/> returnedClass() {
return JSONObject.class;
}
....
}
@org.hibernate.annotations.TypeDef(name = "JSONType", typeClass = JSONObject.class)
@Column
@Type(type = "JSONType")
private JSONObject data;
public class MyPostgreSQL94Dialect extends PostgreSQL94Dialect {
public MyPostgreSQL94Dialect() {
this.registerColumnType(Types.JAVA_OBJECT, "jsonb");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question