Closed shopera007 closed 2 months ago
SQL is declarative, so the order or joins in this particular case shouldn't matter. What problem are you trying to solve?
Thank you for your response. In my query, I use both INNER JOIN and LEFT JOIN. If I perform the INNER JOIN between the product and my CTE first, there will be fewer rows for the subsequent joins, leading to better query optimization. For example, if we have three tables A, B, and C:
Performing A INNER JOIN B LEFT JOIN C will generally be more efficient than A LEFT JOIN B INNER JOIN C.
Can you try adding the following before calling this.entityViewManager.applySetting(...)
:
criteriaBuilder.leftJoinDefault("tags", "t")
I think that this might change the join order at least in the HQL that is produced, though Hibernate ORM could still re-order joins potentially.
It worked as expected. I just need to arrange all the LEFT JOIN clauses in the desired order within my query.
Thank you so much for your help; you saved me a lot of time!
Glad it worked out for you!
This is my code and I'm not finding any way to force blaze to first join with the CTE before doing implicit joins from the entity view :
Result query :
How can i please force Blaze to first join with CTE sub query then move on to the next joins. Thank you :)