valueCollectionDatasource - how to use Filter

HI,

is there any way to use the filter also for valueCollectionDatasource ?

When I use the query with a where everything is working fine. See first example

where Clausel - works
Code blocks


<dsContext>
    <valueCollectionDatasource id="newDs">
        <query>
            <![CDATA[select e.bezeichnung, e.wertenum, sum(b.betrag) from tabletest$Firma e 
            left join e.bestellungen b
            where (e.id = :component$firmalookupField) group by e.bezeichnung, e.wertenum]]>
        </query>
        <properties idProperty="bezeichnung">
            <property class="com.company.tabletest.entity.Firma" name="bezeichnung"/>
            <property class="com.company.tabletest.entity.Firma" name="wertenum"/>
            <property datatype="decimal" name="sum"/>
        </properties>
    </valueCollectionDatasource>
    <collectionDatasource id="firmaDs" class="com.company.tabletest.entity.Firma" view="_minimal">
        <query>
            <![CDATA[select e from tabletest$Firma e]]>
        </query>
    </collectionDatasource>
</dsContext>

When I try to use a filter instead, I will get an error (comma missing)

Filter - does not work
Code blocks


<dsContext>
    <valueCollectionDatasource id="newDs">
        <query>
            <![CDATA[select e.bezeichnung, e.wertenum, sum(b.betrag) from tabletest$Firma e left join e.bestellungen b group by e.bezeichnung, e.wertenum]]>
            <filter>
                <c>e.id = :component$firmalookupField</c>
            </filter>
        </query>
        <properties idProperty="bezeichnung">
            <property class="com.company.tabletest.entity.Firma" name="bezeichnung"/>
            <property class="com.company.tabletest.entity.Firma" name="wertenum"/>
            <property datatype="decimal" name="sum"/>
        </properties>
    </valueCollectionDatasource>
    <collectionDatasource id="firmaDs" class="com.company.tabletest.entity.Firma" view="_minimal">
        <query>
            <![CDATA[select e from tabletest$Firma e]]>
        </query>
    </collectionDatasource>
</dsContext>

Regards,
Torsten

Hi Torsten,

can you share the error that is showing up in the logs? - Thanks

Bye
Mario

Sure,

here is the error:
Code blocks


JPQLException: 
Exception Description: Syntax error parsing [select e.bezeichnung, e.wertenum, sum(b.betrag) from tabletest$Firma e left join e.bestellungen b group by e.bezeichnung e.wertenum]. 
[120, 121] The GROUP BY clause has 'e.bezeichnung' and 'e.wertenum' that are not separated by a comma.

Hi,

so generally it is possible to use the filter tag. I attached a minimal example that shows it. Perhaps you can start from thereā€¦

It might be that it has something to do with the additional attributes? You can try to extend the example and add your attributes to it and see when it breaks.

Bye
Mario

cuba-example-valueDs-filter.zip (40.9K)