Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
V2 2.0.10
-
None
-
None
Description
We are using the olingo JPA processor and our entity has a field which is a java Enum.
When we issue the following OData request
/Issues/$count?$filter=Status eq 'NEW'
(where Status is the ENUM field), we are getting an exception
2018-10-19 10:43:13.299 ERROR 3116 — [o-auto-1-exec-4] c.s.c.p.o.ProjectODataJPAErrorCallback : org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException: "OData - JPA Runtime: JPA query syntax is not correct"
java.lang.IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter 1 with expected type of class com.sap.copin.project.model.enums.IssueStatus from query string SELECT COUNT ( E1 ) FROM Issue E1 WHERE (E1.status LIKE ?1 ESCAPE '\').
With olingo 2.0.8 the generated SQL was:
SELECT COUNT ( E1 ) FROM Issue E1 WHERE (E1.status = 'NEW')
With olingo 2.0.10 the generated SQL is:
SELECT COUNT ( E1 ) FROM Issue E1 WHERE (E1.status LIKE ?1 ESCAPE '\')
Using the prepared statement is good, but this breaks ENUM support.
Olingo should do a Enum.valueOf() call for Enum fields that are used in an "equals" $filter expression to make it work again.
A similar feature is already implemented in JPAEntity.setProperty, but this does not help for filtering.