SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
123 stars 76 forks source link

Request fails with navigation property in the $select clause #110

Open kyriba-jchmiel opened 3 years ago

kyriba-jchmiel commented 3 years ago

As a reference let's use: https://services.odata.org/V4/TripPinService/$metadata#People and query https://services.odata.org/V4/TripPinService/People?$select=LastName,Photo

For People entity Photo property is a navigation property and server handles the query without a problem.

In my case putting navigation property in the select clause causes error. java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key ODataJPAQueryException.QUERY_PREPARATION_INVALID_SELECTION_PATH at java.base/java.util.ResourceBundle.getObject(Unknown Source) at java.base/java.util.ResourceBundle.getString(Unknown Source) at com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAMessageTextBuffer.getText(ODataJPAMessageTextBuffer.java:45) at com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAMessageTextBuffer.getText(ODataJPAMessageTextBuffer.java:50) at com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessException.getMessage(ODataJPAProcessException.java:92) at org.apache.olingo.server.core.ODataExceptionHelper.basicServerError(ODataExceptionHelper.java:161) at org.apache.olingo.server.core.ODataExceptionHelper.createServerErrorObject(ODataExceptionHelper.java:145) at org.apache.olingo.server.core.ODataHandlerImpl.process(ODataHandlerImpl.java:117) at org.apache.olingo.server.core.ODataHttpHandlerImpl.process(ODataHttpHandlerImpl.java:74)

I believe that navigation properties should be ignored, but right now they are not and when in com.sap.olingo.jpa.processor.core.query.JPAJoinQuery query is build exception is thrown.

kulinskyvs commented 3 years ago

Indeed, looks like the oData specification (at least v4) requires the navigation link to be presented in the response (instead of failure)

If a navigation property is specified in $select, then the corresponding navigation link is represented in the response. If the navigation property also appears in an $expand query option, then it is additionally represented as inline content.

I'm also observing that the request is failing if a navigation property is presented in $select

java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key ODataJPAQueryException.QUERY_PREPARATION_INVALID_SELECTION_PATH
    at java.base/java.util.ResourceBundle.getObject(ResourceBundle.java:564)
    at java.base/java.util.ResourceBundle.getString(ResourceBundle.java:521)
    at com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAMessageTextBuffer.getText(ODataJPAMessageTextBuffer.java:45)
    at com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAMessageTextBuffer.getText(ODataJPAMessageTextBuffer.java:50)
    at com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessException.getMessage(ODataJPAProcessException.java:92)
    at org.apache.olingo.server.core.ODataExceptionHelper.basicServerError(ODataExceptionHelper.java:161)
    at org.apache.olingo.server.core.ODataExceptionHelper.createServerErrorObject(ODataExceptionHelper.java:145)
    at org.apache.olingo.server.core.ODataHandlerImpl.process(ODataHandlerImpl.java:117)
    at org.apache.olingo.server.core.ODataHttpHandlerImpl.process(ODataHttpHandlerImpl.java:74)
    at com.kyriba.olingo.server.api.ObservableODataHttpHandler.doProcess(ObservableODataHttpHandler.java:90)
    at com.kyriba.olingo.server.api.ObservableODataHttpHandler.process(ObservableODataHttpHandler.java:75)
    at org.apache.olingo.server.core.ODataHttpHandlerImpl.process(ODataHttpHandlerImpl.java:88)
    at com.sap.olingo.jpa.processor.core.api.JPAODataGetHandler.processInternal(JPAODataGetHandler.java:162)
    at com.sap.olingo.jpa.processor.core.api.JPAODataGetHandler.process(JPAODataGetHandler.java:98)