'Select from' using 'With' clause and static literals CTE

Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

In the meantime, you can try nest the query group in a subquery.

JpaCriteriaQuery<Tuple> cteSubquery = cb.createTupleQuery();
JpaSubQuery<Tuple> data1 = cteSubquery.subquery(Tuple.class);
data1.multiselect( cb.literal( "any uuid 1" ).alias( "col1" ), cb.literal( "any uuid 2" ).alias( "col2" ) );
List<JpaSubQuery<Tuple>> dataN = new ArrayList<>();
JpaSubQuery<Tuple> data2 = cteSubquery.subquery(Tuple.class);
data2.multiselect( cb.literal( "any uuid 3" ).alias( "col1" ), cb.literal( "any uuid 4" ).alias( "col2" ) );
dataN.add( data2 );

JpaCriteriaQuery<RealTable> cq = cb.createQuery( RealTable.class );
JpaRoot<Tuple> subqueryRoot = cteSubquery.from( cb.unionAll( data1, dataN.toArray( new JpaSubQuery[0] ) ) );
cteSubquery.multiselect( subqueryRoot.get("col1").alias("col1"), subqueryRoot.get("col2").alias("col2") );
JpaCteCriteria<Tuple> dataCte = cq.with( cteSubquery );
JpaRoot<RealTable> root = cq.from( RealTable.class );
JpaJoin<Tuple> cteJoin = root.join( dataCte );
cteJoin.on( cb.and( cb.equal( root.get( "col1" ), cteJoin.get( "col1" ) ), cb.equal( root.get( "col2" ), cteJoin.get( "col2" ) ) ) );