Could not determine recommended jdbctype error for entity Queue

I have two tables which are interconnected by relationship.

One to many relationship between Queue and QueueUser which is bidirectional.

We are creating a subquery as
Subquery subQuery = cq.subquery(Queue.class);
Root subRoot = subQuery.from(QueueUser.class);
subQuery.where(cb.equal(subRoot.get(“userName”), userName));“queue”).as(Queue.class));

This query works well with existing hibernate 5.6 but now we have migrated to hibernate 6.2.13
Now it is failing and giving error as could not determine recommended jdbctype for queue entity.

Can you please help with this issue.

Hello, why do you need to cast .as( Queue.class )? I believe you could simply remove that and the query should work. Casting to entity types is wrong, if you’re trying to restrict to a specific inheritance subtype you should use the treat() operator instead: Hibernate ORM User Guide.