How to map a JSON column with H2, JPA, and Hibernate

I just came across this problem working with the JSONB column type – the binary version of the JSON type, which doesn’t map to TEXT.

For future reference, you can define a custom type in H2 using CREATE DOMAIN, as follows:

CREATE domain IF NOT EXISTS jsonb AS other;

This seemed to work for me, and allowed me to successfully test my code against the entity.

Source: https://objectpartners.com/2015/05/26/grails-postgresql-9-4-and-jsonb/

Leave a Comment