Module is.codion.framework.domain
Interface EntitySelectQuery.Builder.WithAsStep
- Enclosing interface:
EntitySelectQuery.Builder
public static sealed interface EntitySelectQuery.Builder.WithAsStep
Adds a common table expression (CTE) to the query.
CTEs are prepended to the query using the WITH clause.
Example:
EntitySelectQuery.builder()
.with("active_customers")
.as("SELECT * FROM customer WHERE active = true")
.from("active_customers")
.columns("id, name")
.build()
Generates:
WITH active_customers AS (SELECT * FROM customer WHERE active = true)
SELECT id, name
FROM active_customers
-
Method Summary
-
Method Details
-
as
- Parameters:
query- the CTE query, without the WITH keyword- Returns:
- this Builder instance
- Throws:
IllegalArgumentException- if query contains the WITH keyword
-