> Here the aliases `o` don't ever infringe on each other. So imo we should allow that.
Sounds good > Here the aliases `c` do infringe. In the subquery, we don't really know > which reference the `c` alias should resolve to. We *could* here assuming > that the subquery is uncorrelated. Bu without this rule we really would > not know that the subquery is correlated Out of curiosity, Couldn't for this case assume that the second alias overrides the first. This might cause some hard to spot errors, though. On Wed, Oct 7, 2015 at 3:00 PM, Steve Ebersole <st...@hibernate.org> wrote: > At the moment the alias registry is global for the whole query. I propose > that we should scope this by "query spec" (combined with parent). The > reason being that reusing the same alias in unrelated subqueries is > perfectly fine. > > select ... > from Customer c > where c.id in ( > select o.customer.id > from Order o > ... > ) > or c.id in ( > select c1.id > from Outstanding o > ... > ) > > Here the aliases `o` don't ever infringe on each other. So imo we should > allow that. > > The piece about checking the parent is for a case like: > select ... > from Customer c > where c.id in ( > select c.id > from Order o > join o.customer c > ... > ) > > Here the aliases `c` do infringe. In the subquery, we don't really know > which reference the `c` alias should resolve to. We *could* here assuming > that the subquery is uncorrelated. Bu without this rule we really would > not know that the subquery is correlated. Hopefully that makes sense, what > I am getting at. > > WDYT? > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev