As spotted by Jens Schauder, the issue comes from https://github.com/hibernate/hibernate-orm/pull/2676 . The added alias is a component of the path itself and there is a cache for the paths so you end up having the alias set in all the paths using the same attribute name. Adding a condition in render() is not sufficient as it's not really feasible IMHO to know if we are at the root of the select (e.g. what if you're in a function? we have a function stack but it looks like it's not properly implemented everywhere, typically it does not seem our aggregation functions add elements to the function stack). And I suppose it's possible to define custom functions. Vlad Mihalcea I think we should probably revert the patch for now and maybe revisit this in 6 if there's a better way of doing that. |