# HIbernate ORM UserType mapping

**URL:** https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973
**Category:** Hibernate ORM
**Created:** [February 5, 2024, 12:22pm UTC](https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973 "2024-02-05T12:22:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Zuka](https://avatars.discourse-cdn.com/v4/letter/z/6f9a4e/32.png) [@Zuka](https://discourse.hibernate.org/u/Zuka)
#### Post date: [February 5, 2024, 12:22pm UTC](https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973/1 "2024-02-05T12:22:00Z")

</div>

Hello, how can i join on UserType objects with jpql ?  
in hibernate 5 it worked fine , but on hibernate 6 it throws error :  
Caused by: java.lang.IllegalArgumentException: Can’t compare test expression of type [BasicSqmPathSource(foo: Foo.class)] with element of type [BasicSqmPathSource(id : Long)]

this is my entity representation

```java
public class A {

    @Id
    @Column(name = "ID")
    private long id;

    @Column(name = "FOO")
    @Type(value = com.example.foo.FooUserType.class)
    private Foo foo;

//getters and setters
}

public class FooUserType implements UserType< Foo> {
    @Override
    public int getSqlType() {
        return Types.BIGINT;
    }

    @Override
    public Class<Foo> returnedClass() {
        return Foo.class;
    }

    @Override
    public nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException {
      //implementation

//return new Foo();
    }

}

```

Foo is foreign key to another table and in getter method i fetch data and set to my object,

```java
em.createQuery("select a from FooTable f inner join a.foo=f.id")

```

this query in hibernate 5 had compilation error, but when i ran it it joined fine, but in hibernate 6 gives me error, which i have alreadey mentioned.

Thanks forehead

---

<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: [February 5, 2024, 12:30pm UTC](https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973/2 "2024-02-05T12:30:53Z")

</div>

We are aware of this and are in the process of fixing. Also see [HHH-17693 Cannot use 'like' operand when an AttributeConverter is used to convert the attribute in a String by mbladel · Pull Request #7768 · hibernate/hibernate-orm · GitHub](https://github.com/hibernate/hibernate-orm/pull/7768)

---

<div class="post-metadata">

### Author: ![Zuka](https://avatars.discourse-cdn.com/v4/letter/z/6f9a4e/32.png) [@Zuka](https://discourse.hibernate.org/u/Zuka)
#### Post date: [February 6, 2024, 8:28am UTC](https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973/3 "2024-02-06T08:28:15Z")

</div>

Thanks for the answer and In which version will it be fixed?

---

<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: [February 6, 2024, 10:06am UTC](https://discourse.hibernate.org/t/hibernate-orm-usertype-mapping/8973/4 "2024-02-06T10:06:39Z")

</div>

See [Maintenance Policy - Hibernate](https://hibernate.org/community/maintenance-policy/) for details.
