@enum and the keyword NEW in screen XML

Hi

A small quirk while using @enum macro in screen xml, sample query below.

            <loader id="stockDl">
                <query>
                    <![CDATA[
                    select e from svp_CarTransaction e
                    where e.state = @enum(com.company.svp.entity.CarTransactionState.NEW)
                    or e.state = @enum(com.company.svp.entity.CarTransactionState.ON_SALE)
                   ]]>
                </query>
            </loader>

It will not work as is, producing the following error :

Errors found for input jpql:[select e from svp_CarTransaction e                     where e.state = @enum(com.company.svp.entity.CarTransactionState.NEW)                     or e.state = @enum(com.company.svp.entity.CarTransactionState.ON_SALE)]
CommonErrorNode [<unexpected: [@33,62:62='.',<68>,1:62], resync=e.state = @enum(com.company.svp.entity.CarTransactionState.NEW)>]

However interestingly, if you put the same query in a integration test it will work.

    @Test
    public void testQuery() {
        String query1 = "select e from svp_CarTransaction e\n" +
                "                    where e.state = @enum(com.company.svp.entity.CarTransactionState.NEW)\n";
        execute(query1, null);

        String query2 = "select e from svp_CarTransaction e\n" +
                "                    where e.state = @enum(com.company.svp.entity.CarTransactionState.NEW)\n" +
                "                    or e.state = @enum(com.company.svp.entity.CarTransactionState.ON_SALE)";
        execute(query2, null);
    }

Changing the screen xml in this way makes it work.

 <loader id="stockDl">
                <query>
                    <![CDATA[
                    select e from svp_CarTransaction e
                    where e.state = 10
                    or e.state = @enum(com.company.svp.entity.CarTransactionState.ON_SALE)
                   ]]>
                </query>
            </loader>

Or by refactoring enum value from “NEW” to “NEW_”.

It seems to mean there is logic in the screen xml that is sensible to “new” keyword whereas in code executed directly through core there is not.

Regards
Michael

Hi,
Thank you for reporting the problem. Issue has been created.
Regards