You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "arathi m (JIRA)" <ji...@apache.org> on 2015/06/03 02:30:49 UTC

[jira] [Created] (OLINGO-683) Unable to query an entity using an int id

arathi m created OLINGO-683:
-------------------------------

             Summary: Unable to query an entity using an int id
                 Key: OLINGO-683
                 URL: https://issues.apache.org/jira/browse/OLINGO-683
             Project: Olingo
          Issue Type: Bug
          Components: odata2-jpa
    Affects Versions: V2 2.0.3
            Reporter: arathi m


I have a MySQL table with an int primary key. I exposed my database table using an Odata service using Olingo-odata2 JPA processor. When I query my entity set using this URL:
http://host/emplist-web/emplist.svc/Customers(1)

I get "Requested Resource not found exception". But the record exists with id=1.
I debugged code and found that the JPQL generated is Select E1.Customer from Customers E1 where E1.id=1L. But since my id is an int, the JPQL should be  Select E1.Customer from Customers E1 where E1.id=1.

I further debugged and the error is in evaluateComparingExpression of org.apache.olingo.odata2.jpa.processor.core.ODataExpressionParser 
evaluateComparingExpression method.

This code:
else if (EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance().isCompatible(edmSimpleType)) {
      uriLiteral = uriLiteral + JPQLStatement.DELIMITER.LONG; //$NON-NLS-1$
    }

adds the erroneous JPQL I mentioned earlier. The fix would be to replace above with this
else if(EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance().equals(edmSimpleType))
    {
    	uriLiteral = uriLiteral;
    }
    else if (EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance().isCompatible(edmSimpleType)) {
      uriLiteral = uriLiteral + JPQLStatement.DELIMITER.LONG; //$NON-NLS-1$
    }









--
This message was sent by Atlassian JIRA
(v6.3.4#6332)