As of Hibernate 6, the implementation regarding #getSingleResult() changed which effectively disabled the automatic deduplication logic. Since Hibernate 7.3 the feature is fully removed and the query itself has to ensure, that only a single result is returned. This is also possible by adding a ResultListTransformer (see https://docs.hibernate.org/orm/7.3/migration-guide/#_result_deduplication and https://github.com/hibernate/hibernate-orm/pull/11470/changes).
This means, that in case of Hibernate, we should add the mentioned transformer or provide a own implementation, in case the provided one is not functional equivalent to pre-hibernate-6 times.
query.setResultListTransformer(ResultListTransformer.uniqueResultTransformer())
An other solution would be to generally provide a custom solution for this and run a custom deduplication after the query returned it's result. This would apply to all possible JPA vendors.
What is the preferred solution? Hibernate specific or QueryDSL sepcific?
As of Hibernate 6, the implementation regarding
#getSingleResult()changed which effectively disabled the automatic deduplication logic. Since Hibernate 7.3 the feature is fully removed and the query itself has to ensure, that only a single result is returned. This is also possible by adding aResultListTransformer(see https://docs.hibernate.org/orm/7.3/migration-guide/#_result_deduplication and https://github.com/hibernate/hibernate-orm/pull/11470/changes).This means, that in case of Hibernate, we should add the mentioned transformer or provide a own implementation, in case the provided one is not functional equivalent to pre-hibernate-6 times.
An other solution would be to generally provide a custom solution for this and run a custom deduplication after the query returned it's result. This would apply to all possible JPA vendors.
What is the preferred solution? Hibernate specific or QueryDSL sepcific?