You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Darren Lindley (JIRA)" <ji...@apache.org> on 2016/04/16 02:56:25 UTC

[jira] [Comment Edited] (OLINGO-930) Filter condition on an expanded attribute fails with ClassCastException

    [ https://issues.apache.org/jira/browse/OLINGO-930?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15243913#comment-15243913 ] 

Darren Lindley edited comment on OLINGO-930 at 4/16/16 12:55 AM:
-----------------------------------------------------------------

[~chrisam], 
it is supported or at least it does work (for filtering on a many to 1 NOT a 1 to many) and works fine if I change that bit of code. 

the one to many doesn't work still though as the JPQL generated isn't correct but that was beyond the scope of my bug report (as i stated Cars->Manufacturer and not Manufacturer->Cars) but still would be a good code fix to do to at least allow users to do many to one filtering.

the 1 to many could be more gracefully trapped with
{code}


  private static String getPropertyName(final CommonExpression whereExpression) throws EdmException, ODataNotImplementedException {
    EdmTyped edmTyped = ((PropertyExpression) whereExpression).getEdmProperty();
    if (edmTyped.getMultiplicity() == EdmMultiplicity.MANY) {
      throw new ODataNotImplementedException();
    }
    EdmMapping mapping = ((EdmMappable) edmTyped).getMapping();
    return mapping != null ? mapping.getInternalName() : edmTyped.getName();
  }
{code}


was (Author: dazzal):
Christian, 
it is supported or at least it does work (for filtering on a many to 1 NOT a 1 to many) and works fine if I change that bit of code. 

the one to many doesn't work still though as the JPQL generated isn't correct but that was beyond the scope of my bug report (as i stated Cars->Manufacturer and not Manufacturer->Cars) but still would be a good code fix to do to at least allow users to do many to one filtering.

the 1 to many could be more gracefully trapped with
{code}


  private static String getPropertyName(final CommonExpression whereExpression) throws EdmException, ODataNotImplementedException {
    EdmTyped edmTyped = ((PropertyExpression) whereExpression).getEdmProperty();
    if (edmTyped.getMultiplicity() == EdmMultiplicity.MANY) {
      throw new ODataNotImplementedException();
    }
    EdmMapping mapping = ((EdmMappable) edmTyped).getMapping();
    return mapping != null ? mapping.getInternalName() : edmTyped.getName();
  }
{code}

> Filter condition on an expanded attribute fails with ClassCastException
> -----------------------------------------------------------------------
>
>                 Key: OLINGO-930
>                 URL: https://issues.apache.org/jira/browse/OLINGO-930
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.5, V2 2.0.6
>            Reporter: Darren Lindley
>            Assignee: Christian Amend
>
> i installed the sample cars/manufacturers application and tried this query:
> http://localhost:8080/MyFormula.svc/Cars?$filter=ManufacturerDetails/Name%20eq%20%27SuperCar%27&$expand=ManufacturerDetails
> this fails with the message:
> class java.lang.ClassCastException : org.apache.olingo.odata2.core.edm.provider.EdmNavigationPropertyImplProv cannot be cast to org.apache.olingo.odata2.api.edm.EdmProperty
> This appears to come from ODataExpressionParser:
> {code:title=ODataExpressionParser.java|borderStyle=solid}
>   private static String getPropertyName(final CommonExpression whereExpression) throws EdmException {
>     EdmProperty property = ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty());
>     EdmMapping mapping = property.getMapping();
>     String name = mapping != null ? mapping.getInternalName() : property.getName();
>     return name;
>   }
> {code}
> changing this to :
> {code:title=ODataExpressionParser.java|borderStyle=solid}
>   private static String getPropertyName(final CommonExpression whereExpression) throws EdmException {
>     EdmTyped edmTyped = ((PropertyExpression) whereExpression).getEdmProperty();
>     EdmMapping mapping = ((EdmMappable) edmTyped).getMapping();
>     return mapping != null ? mapping.getInternalName() : edmTyped.getName();
>   }
> {code}
> resolves the issue.



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