[hibernate-dev] SQM - alias registry
Davide D'Alto
daltodavide at gmail.com
Wed Oct 7 10:15:13 EDT 2015
> 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 <steve at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
More information about the hibernate-dev
mailing list