[ 
https://issues.apache.org/jira/browse/OLINGO-930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Darren Lindley updated OLINGO-930:
----------------------------------
    Description: 
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.

  was:
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}


> 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
>    Affects Versions: V2 2.0.5, V2 2.0.6
>            Reporter: Darren Lindley
>
> 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)

Reply via email to