cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

My API-Call:


https://apisalesdemo8.successfactors.com/odata/v2/EmployeeTime?$select=userId,timeType,timeTypeNav/e...

The result is:


I am using odata-generator maven plugin to generate classes from edmx file.

And this is how I do the query in code:

        final List<EmployeeTime> employeeTimes =
                new DefaultEmployeeTimeService().withServicePath("/odata/v2/")
                .getAllEmployeeTime()
                .select(
                    EmployeeTime.USER_ID, 
                    EmployeeTime.TIME_TYPE, 
                    EmployeeTime.EXTERNAL_CODE, 
                    EmployeeTime.START_DATE, 
                    EmployeeTime.START_TIME, 
                    EmployeeTime.END_DATE, 
                    EmployeeTime.END_TIME)
                .top(10)
                .executeRequest(httpDestination);

I would like to filter the start date with value null. So my code is:

 final List<EmployeeTime> employeeTimes =
                new DefaultEmployeeTimeService().withServicePath("/odata/v2/")
                .getAllEmployeeTime()
                .select(
                    EmployeeTime.USER_ID, 
                    EmployeeTime.TIME_TYPE, 
                    EmployeeTime.EXTERNAL_CODE, 
                    EmployeeTime.START_DATE, 
                    EmployeeTime.START_TIME, 
                    EmployeeTime.END_DATE, 
                    EmployeeTime.END_TIME)

                 .filter(EmployeeTime.START_TIME.eq(null)
 
                .top(10)
                .executeRequest(httpDestination);

but I got an error:

com.sap.cds.services.impl.ContextualizedServiceException: Cannot invoke "Object.getClass()" because "value" is null (service 'EmployeeTimeService', event 'READ', entity 'EmployeeTimeService.EmployeeTime')

Does it not support filter with value null?

This is the code in oDataType.class (com.sap.cloud.sdk.odatav2.connectivity) which caused the problem.

0 Likes
View Entire Topic
0 Likes

Hi Edwin,

We're investigating this case. In the meantime, there's a workaround to use an unchecked, custom filter expression from our OData Client API:

.filter(
  new UncheckedFilterExpression<>(
    FieldReference.of(EmployeeTime.START_TIME.getFieldName())
      .equalTo(Expressions.Operand.NULL)))

If other values than null are possible you can use

Expressions.createOperand( yourValue )

instead of

Expressions.Operand.NULL

Kind regards

Alexander