KeyValueCollection Data Container with Enum value

Hi,
I have an Entity with a field of type Enum. I am trying to use KeyValueCollection data container and display the data in dataGrid.

Here is details:

SQL

    select e.salesDataSet, sum(e.pd01Amount), sum(e.pd02Amount), sum(e.pd03Amount), sum(e.pd04Amount),
sum(e.pd05Amount), sum(e.pd06Amount), sum(e.pd07Amount), sum(e.pd08Amount), sum(e.pd09Amount),
sum(e.pd10Amount), sum(e.pd11Amount), sum(e.pd12Amount) from erp_SalesSummary e group by e.salesDataSet 

Here the salesDataSet is Enum class.

Here are the properties defined in the screen

image

When I run the application I get no info displayed under the column salesDataSet

image

if I define the columns as follows,
image

I get the following outcome, but I need to display the enum name instead.
image

Thanks for any help.

Hi Mortoza,

Thank you for reporting the problem.
The KeyValueCollectionContainer does not support enum properties at the moment. Created issue.

As a workaround, you can use case statement in your JPQL query and a corresponding string property in the container definition, for example:

<keyValueCollection id="aggregateDc">
    <loader id="aggregateDl">
        <query><![CDATA[
        select case 
                when (e.status = 'A') then 'Active' 
                when (e.status = 'H') then 'On Hold' 
                else '' 
                end, 
               sum(e.amount)
        from demo_Order e 
        group by e.status]]></query>
    </loader>
    <properties>
        <property name="status" datatype="string"/>
        <property name="amount" datatype="double"/>
    </properties>
</keyValueCollection>

1 Like