Question

with the following code I get an error in my sql statement:

Expression<Number> difference = queryBuilder.diff(A, B);
Predicate differenceGEtoZero = queryBuilder.ge(difference, new Long(0));
CriteriaBuilder.Case<Number> when = queryBuilder.<Number>selectCase().when(
                differenceGEtoZero, difference
        );
        queryDefinition.select(
                queryBuilder.construct(
                        State.class,
                        root.get("object"),
                        queryBuilder.sum(
                                when.otherwise(new Long(0))
                        )
                )
        );

I get this sql statement containing an error in CASE'S THEN part:

SUM(
      CASE WHEN ((t1.A - t1.B) >= 0) 
      THEN ((t1.A - t1.B) >= 0)    //'>= 0'  should not appear here!!!
      ELSE 0 
      END ) 

I expected only the difference appearing ((t1.A - t1.B), not again a condition >=0.

I am using this version of the libs: org.apache.openejb:javaee-api:6.0-5 and eclipseLink 2.3.2 as provider

Could you please tell me what's wrong in the code?

Thank you in advance. Nic

Was it helpful?

Solution

Seems a bug solved by following versions of eclipseLink.

With 2.5.1 everything is working fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top