Creat a package-info file in the models package and put the following contents in there:
@org.hibernate.annotations.TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
package com.ourproject.model;
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
I used JsonBinaryType
in hibernate-types-52
library.
Then in the entity class, I removed columnDefinition="jsonb"
from the @Column
and only used @Type(type = "jsonb")
This way, for the product, hibernate would map column to jsonb
type.
Then in the test folder inside the same package I added package-info
with this contents:
@org.hibernate.annotations.TypeDef(name = "jsonb", typeClass = TextType.class)
package com.ourproject.model;
import org.hibernate.type.TextType;
Now when we run maven test hibernate generates varchar(2147483647)
column type for the jsonb type and it solved.
I was already using
JsonType
and still was gettingNo Dialect mapping for JDBC type: 1111
.The workarounds from Vlad to create your own extended Dialect https://vladmihalcea.com/hibernate-no-dialect-mapping-for-jdbc-type/ only partially solved the problem for me. Plus I'm using different Dialects for different Production DBs (Oracle and Postgres) and it wasn't easy to configure this for my tests.
So in the end following all the advice contained above was the cleanest (and only solution) I got to work so far.
I'm using Spring Boot and created 2 package-info.json Files (one for test against H2 and one for production against Postgres) and removed the
@TypeDef
from the Class. I'm not using Flyway.