# @JdbcTypeCode on @MapKeyColumn

**URL:** <https://discourse.hibernate.org/t/jdbctypecode-on-mapkeycolumn/7696>\
**Category:** Hibernate ORM\
**Created:** [May 25, 2023, 3:19pm UTC](https://discourse.hibernate.org/t/jdbctypecode-on-mapkeycolumn/7696 "2023-05-25T15:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cendretoundra](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cendretoundra](https://discourse.hibernate.org/u/cendretoundra)\
**Post date:** [May 25, 2023, 3:19pm UTC](https://discourse.hibernate.org/t/jdbctypecode-on-mapkeycolumn/7696/1 "2023-05-25T15:19:43Z")

</div>

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

```auto
    @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

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [May 25, 2023, 8:29pm UTC](https://discourse.hibernate.org/t/jdbctypecode-on-mapkeycolumn/7696/2 "2023-05-25T20:29:56Z")

</div>

This looks like a bug. Please create an issue in the issue tracker([https://hibernate.atlassian.net](https://hibernate.atlassian.net)) with a test case([hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java)) that reproduces the issue.

---

<div class="post-metadata">

**Author:** ![cendretoundra](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cendretoundra](https://discourse.hibernate.org/u/cendretoundra)\
**Post date:** [November 24, 2023, 2:49pm UTC](https://discourse.hibernate.org/t/jdbctypecode-on-mapkeycolumn/7696/3 "2023-11-24T14:49:22Z")

</div>

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

```auto
    @MapKeyJdbcTypeCode(java.sql.Types.VARCHAR)

```

as well as the others and it works
