Skip to content

Common Table Expression support for Hibernate #1528

@Mart1031y

Description

@Mart1031y

Important Notice

Thank you for opening an issue! Please note that, as outlined in the README, I currently only work on feature requests or bug fixes when sponsored. Balancing this project with professional and personal priorities means I have a very limited amount of effort I can divert to this project.

You must put in the work to address this issue, or it won't be addressed.

  • I am willing to put in the work and submit a PR to resolve this issue.

Is your feature request related to a problem? Please describe.
Common Table Expressions (CTEs) are a way in SQL to execute subqueries as part of a larger query.
Although JPA does not support them, Hibernate does since 6.2: https://in.relation.to/2023/02/20/hibernate-orm-62-ctes/

I'd like to expose a simple version of that through querydsl, focusing on simple queries and "materialized" hint flags.
Recursive CTEs are not in scope, for now.

Describe the solution you'd like
Querydsl already has Hibernate-specific classes, so we could limit the changes only to that.
AbstractHibernateQuery would be extended with similar methods to what SQLCommonQuery already has, just limited to what Hibernate actually supports.

Describe alternatives you've considered
As this is a new feature not yet supported by Querydsl, there are no real alternatives.
Subqueries in joins could theoretically work, but as far as I know, Hibernate does not support that.
Subqueries in where clause is limiting as one cannot reuse the result of the query for multiple columns.

Additional context
I'd like to add the feature to the 6.x release of querydsl as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions