Dynamic SQL with Hibernate

27 views Asked by At

I want to build a dynamic query depending on the incoming request parameters. I have a general query with a lot of sql statements. But dependent on the incoming request parameter, some of the select statements could be skipped, meaning there is no need than to make a select on Table A for example. I am using native query inside Hiberate, but is their any possibility to mark the line with a condition.

WITH 
A AS ( //take this only when we have a request parameter like astat = true
SELECT ID
FROM A
WHERE...),
B AS (
SELECT ID
FROM B
WHERE ...)
SELECT ID
FROM A
JOIN ...
UNION ALL
SELECT ID
FROM B
JOIN ...
0

There are 0 answers