Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-683

Unable to query an entity using an int id

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • V2 2.0.3
    • V2 2.0.5
    • odata2-jpa
    • None

    Description

      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$ }

      Attachments

        Activity

          People

            chandan.v.a Chandan V.A
            arathim arathi m
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: