Join unrelated entities using JPA or Hibernate Criteria


#1

Is there any possibility of join unrelated entities using JPA criteria or hibernate criteria?

I know this is possible using JPQL, but I was wondering if it is possible to create dynamic queries using unrelated entities.


#2

The JPA Criteria API specification does not provide support for this feature, hence this feature is not implemented by Hibernate as it would require a custom API.

Hibernate Criteria is deprecated and not maintain at all. You should not use it for new projects, as it might be removed in a future version of Hibernate.

However, what exactly is your use case? Maybe you can use an EXISTS with a Subquery to correlate to “unrelated” entities?