Search code examples
spring-data-jdbc

How to express WITH clause in Spring Data relational JDBC?


I would like to write a CTE and/or With clause using the SelectBuilderor Query builder from the project Spring Data Relational.

My query is something like:

WITH p_params
(
       SELECT :param1 AS param_1,
              :param2 AS param_2
       FROM   DUAL)
SELECT *
FROM   my_table mt
WHERE  mt.field1 = param_1;

Is it possible to express a CTE clause with Spring Data relational?

Note: For this example, I can rewrite my query to avoid a With clause but I'm trying to fill the gap between a SQL Macro (dynamically replacing the WITH clause) and Java Code: so it is a prerequisite.


Solution

  • WITH is currently not supported by the SelectBuilder.