Just for reference, this is related to https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#distinct and how we determine the uniqueSemantic in the constructor of ConcreteSqmSelectQueryPlan. We currently default to ListResultsConsumer.UniqueSemantic.ALLOW when the query does not produce “unique” results, which means that when selecting an entity, we will de-duplicate automatically. It’s questionable though if such queries make sense in the first place. Why would you want to see duplicate entries if you do a join on something that alters the cardinality? |