org.hibernate.query.SemanticException Cannot assign expression of type 'java.io.Serializable' to target path 'alias_1388715014.customProperties' of type 'java.util.Map<java.lang.String, java.lang.String>'

Hi,

Recently migrated from SpringBoot 2 to 3 and that also brought in updated version of hibernate.

Had to redefine JSONB properties like so:

@Entity
@Data
public class Job {

    private String jobType;

    @JdbcTypeCode(SqlTypes.JSON)
    @Basic(fetch = FetchType.LAZY)
    private Map<String, String> customProperties;

}

Have a criteria builder which then updates the job like so:

----------------------------- code omitted
        CriteriaUpdate<Job> criteriaUpdate = cb.createCriteriaUpdate(Job.class);
        criteriaUpdate.set("jobType","default");
        criteriaUpdate.set("customProperties", Collections.emptyMap()); // this line causes the error
---------------------------- code omitted

keep getting this error: “stackTrace”:"org.hibernate.query.SemanticException: Cannot assign expression of type ‘java.io.Serializable’ to target path ‘alias_1388715014.customProperties’ of type ‘java.util.Map<java.lang.String, java.lang.String>’\n\tat org.hibernate.query.sqm.internal.TypecheckUtil.assertAssignable(TypecheckUtil.java:384)

<hibernate.version>6.1.7.Final</hibernate.version>
<hibernate-validator.version>8.0.0.Final</hibernate-validator.version>

Regards and thanks in advance,

Deepak

Hibernate ORM 6.1 is not supported anymore. Please update to version 6.4.4.Final.
If you still have problems, please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Sorry my bad just double checked we are on hibernate version 6.4.1.Final

Digging into this a bit more it looks like I started seeing this issue when Hibernate version went from 6.1 to 6.2. I saw the hibernate 6.2 migration guide and it does mention something about JSON mapping changes. I am using a postgres DB and the data is stored as jsonb. Looks like someone already raised this too Mapping Jsonb (postgres) in 6.2.3.Final

Maybe this is the same issue, I don’t know. But either way, if you want that anyone looks into this, please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

cheers, will try to raise it on the board