JPQL Designer - Tuple

I was trying to use the Tuple option to get the result of fields mix of Entities and sum of values and seems the Studio has a very good option but not sure how to get the Entity and values from the resultList and didn’t find any documentation on it.

image

This generates:

final List<DpsAcctStatement> dpsAcctStatementList = dataManager.load(DpsAcctStatement.class)
                .query("select d.dpsAccount, SUM(d.amount) from dps_DpsAcctStatement d where d.dpsAccount.dpsStatus = :dpsAccountDpsStatus1 group by d.dpsAccount")
                .parameter("dpsAccountDpsStatus1", DpsStatus.APPROVED)
                .list();

However, when I run, I get the following exception:


DevelopmentException: DataManager cannot execute query for single attributes

Any code snippets would help

Hello I was facing similar puzzle while creating data aggregate, but I was able to get the tuple option from the query builder functional with key value connection

        <keyValueCollection id="salesDc">
            <properties>
                <property name="sp" class="com.company.test2.entity.Serviceplan"/>
                <property name="price" datatype="int"/>

            </properties>
            <loader id="salesDl">
                <query>
                    <![CDATA[select s.vehicle, AVG(s.price)
                    from Serviceplan s
                    group by s.vehicle ]]>
                </query>
            </loader>
        </keyValueCollection>

I hope this is correct

Yes, and it can also be done in Java using DataManager.loadValues() method.

1 Like

Yes! but my question is more related to the designer that is not generating the code properly.

You are right, JPQL designer should take into account the context of the query.
Created issue: https://youtrack.jmix.io/issue/JST-5558

1 Like

Thank you Konstantin.