Mapping JSON String as Postgresql's JSON type with hibernate

Viewed 1017

How should I tell Hibernate to map a String containing a JSON value to PostgreSQL as PostgreSQL's JSON Type ? Assume I have an attribute like this:

private String foo_json_value;

I have used Gson to convert Foo object to a JSON String and now I want to store this attribute in PostgreSQL. I have learned that PostgreSQL has a JSON data type, so I want to use this datatype instead of string (varchar). What JPA annotation or mapping strategy should I use to be able to store this String as JSON directly?

0 Answers
Related