Select from array of literals using CTE

Hello, dear community,
I’d like to write the following PSQL native query with Criteria API (we are using the 6.4.1 Hibernate version).

  with HT_q (col_1, col_2) as materialized                   
     (
		select col_1, col_2 from unnest(
				array[
					row('123e4567-e89b-12d3-a456-426614174000'::uuid, '123e4567-e89b-12d3-a456-426614174000'::uuid),
			        row('223e4567-e89b-12d3-a456-426614174001'::uuid, '223e4567-e89b-12d3-a456-426614174001'::uuid)
				]
        ) as X (col_1 uuid, col_2 uuid)
     )
     

     select rt1_0.*
     from RealTable rt1_0
     
     inner join HT_q on (
        rt1_0."real_column_1" = HT_q.col_1
        and rt1_0."real_column_2" = HT_q.col_2
    )
     

We have a CTE that selects two columns from an array of rows (unnest array). I’m wondering, is it possible to implement such CTE via the functionality of Criteria API?

Thanks in advance.

Not directly, but you can list the literals explicitly. See 'Select from' using 'With' clause and static literals CTE - #5 by beikov

1 Like