Comment 2 for bug 638930

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I don't have a solution for providing Wildcard.all() to QTuple, but I added another constructor which takes multiple Expression arrays :

    @Test
    public void test(){
        StringPath str1 = new StringPath("str1");
        StringPath str2 = new StringPath("str2");
        StringPath str3 = new StringPath("str3");
        StringPath str4 = new StringPath("str4");
        Expression<?>[] exprs1 = new Expression[]{str1, str2};
        Expression<?>[] exprs2 = new Expression[]{str3, str4};

        assertEquals(Arrays.asList(str1, str2), new QTuple(str1, str2).getArgs());
        assertEquals(Arrays.asList(str1, str2), new QTuple(exprs1).getArgs());
        assertEquals(Arrays.asList(str1, str2, str3, str4), new QTuple(exprs1, exprs2).getArgs());
    }

For example with tables Employee and Department which are joined in a query you could define the QTuple projection like this :

    new QTuple(employee.all(), department.all());

It is not perfect, but works with the FactoryExpression contract. What do you think?

The problem with Wildcard.all() is that it doesn't specify the paths of the projection. QTuple makes the mapping based on the position of the path.