Requested entity could not be found
Lately I was playing around with HCP and Olingo and wanted to expose a JPA model as OData. I created some data using EJB and then tried to read this data via OData. Accessing the collection gave me a list of created entities, but when I tried to access one using its key, I got only the error message: Requested entity could not be found. Exemple: http://localhost:8080/service.svc/Events(8L)
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code/> <message xml:lang="en-US">Requested entity could not be found.</message> </error>
Thing is: the entity was there. I know it (I have DB access), I just could not access it. Turned out that the version of org.eclipse.persistence.jpa I was using does not like when the @ID key is of type long (8L). Using version >= 2.5.2 solved the issue for me. Changing my pom.xml:
<dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.5.2</version> </dependency>
Now I can access the entity using the ID as key in the URL.
More information about this can be found on my private blog.