Add CTE support #5105
Add CTE support
#5105
Replies: 1 comment 8 replies
-
@beikov this looks sensible, but could you please add a couple of example queries showing how this would be used? |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Now that we have implemented support for subqueries in the from clause in 6.1 as part of #3768 and https://hibernate.atlassian.net/browse/HHH-3356, it is time to think about CTE support in HQL and Criteria as well.
The HQL part is pretty simple IMO. I suggest we just do what SQL does here and allow specifying a
WITH
clause forqueryExpression
. The syntax is something like this:The search and cycle clause are applicable to recursive CTEs, i.e. ones that refer to the CTE itself in the second
orderedQuery
when the structure isorderedQuery UNION ALL? orderedQuery
.The SQM API for this is pretty simple:
which would be the way to write this HQL query:
My intention is to add this to the next feature release 6.2 as part of https://hibernate.atlassian.net/browse/HHH-15328. Let's move further discussions to the PR that implements this.
Beta Was this translation helpful? Give feedback.
All reactions