HHH-9305 : HQL FromElement is not reused in some cases resulting in an additional join

(cherry picked from commit a0663f0d6c4185893dbcc2aec4f5fa28ddc8eb35)