cannot assign ‘java.io.Serializable’ to target path ‘alias_1388715014.customProperties’ of type ‘java.util.Map<java.lang.String, java.lang.String>’

34 views Asked by At

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.4.1.Final hibernate-validator version 8.0.0.Final

Regards and thanks in advance

0

There are 0 answers