persistence
persistence copied to clipboard
JPA support for sql WITH clause
Support for the sql WITH clause is missing from JPA. It would be great if the WITH clause is supported in both JPQL and the Criteria API. At the moment it can only be used in native queries (as far as i know).
The WITH clause is a excellent way to simplify and organize complex SQL queries. It has many benefits including readability and re-usage of sql snippets. I think the Criteria API could benefit from this and be more user friendly.
I agree that CTEs should be added to JPA. For now, you can use Blaze-Persistence if you really need this for e.g. recursive CTEs: https://persistence.blazebit.com/documentation/core/manual/en_US/index.html#recursive-ctes