@JdbcTypeCode on @MapKeyColumn

Hello,
In one of my hibernate entity I have the following attribute

    @MapKeyColumn(name = "block_id")
    @Column(name = "target_id")
    @JdbcTypeCode(java.sql.Types.VARCHAR)
    private Map<UUID, UUID> variantMapping = new HashMap<>();

We store this map as an external table and store the uuid as VARCHAR.

However when using this attribute I have the error Cannot cast String as UUID.

Any idea how I could make this work ? I’m using hibernate 6.2.3

This looks like a bug. Please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

1 Like

Hello,
Coming back a bit late but I have found a solution to the problem , we just have to set

    @MapKeyJdbcTypeCode(java.sql.Types.VARCHAR)

as well as the others and it works