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

ClassCastException on Entity update

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • V2 1.0.0, V2 1.1.0
    • V2 1.1.0
    • odata2-jpa
    • None

    Description

      You might want to doublecheck the logic in
      org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntity:write(final Map<String, Object> oDataEntryProperties, final boolean isCreate)

      On line 141 there's an explicit cast to List<ODataEntry>. However I found out that during update, when the property is a 1:1..0 relation to another Entity, the returned type is ODataEntry. And that causes the ClassCastException.

      I managed to solve this for me with a simple if/else block:

      List<ODataEntry> relatedEntries = null;
      if(oDataEntryProperties.get(propertyName) instanceof ODataEntry){
      relatedEntries = new ArrayList<ODataEntry>();
      relatedEntries.add((ODataEntry)oDataEntryProperties.get(propertyName));
      } else {
      relatedEntries = (List<ODataEntry>)oDataEntryProperties.get(propertyName);
      }

      The code is from the 1.1.0-SNAPSHOT master branch HEAD.
      I hope that helps.

      Attachments

        Activity

          People

            chandan.v.a Chandan V.A
            shturec Georgi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: