javaspring-data-jpaodataolingo

Olingo 2.0.6 JPA Extension: EdmComplexTypeImplProv cannot be cast to EdmSimpleType


When using the JPA Extension to scan an entity that includes @Embedded objects the $metadata is created correctly with ComplexTypes. However, when retrieving the entity I receive a ClassCastException:

org.apache.olingo.odata2.core.edm.provider.EdmComplexTypeImplProv cannot be cast to org.apache.olingo.odata2.api.edm.EdmSimpleType

Class: org.apache.olingo.odata2.jpa.processor.core.access.data.JPAEntityParse

Here is the entity code I'm using:

@Entity
public class BORROWER {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Embedded
    protected BORROWER_DETAIL borrower_DETAIL;



    @Embedded
    protected NAME name;


    @ManyToOne
    protected DEAL deal;


    //Mark transient to force orika to skip
    @Transient
    public DEAL getDeal() {
        return deal;
    }

    public void setDeal(DEAL deal) {
        this.deal = deal;
    }

    /**
     * Gets the value of the borrower_DETAIL property.
     * 
     * @return
     *     possible object is
     *
     *     
     */
    public BORROWER_DETAIL getBORROWER_DETAIL() {
        return borrower_DETAIL;
    }

    /**
     * Sets the value of the borrower_DETAIL property.
     * 
     * @param value
     *     allowed object is
     *
     *     
     */
    public void setBORROWER_DETAIL(BORROWER_DETAIL value) {
        this.borrower_DETAIL = value;
    }

    public NAME getName() {
        return name;
    }

    public void setName(NAME name) {
        this.name = name;
    }

    public long getId() {
        return id;
    }
}

Solution

  • Seeing the comment regarding getter/setters being the source of the issue on this bug ticket (also I borrowed parts of the write up for the question):

    https://issues.apache.org/jira/browse/OLINGO-948

    I updated the getter and setter method signatures for borrower_DETAIL, and I'm no longer getting the error. Here is the updated entity code that is working for me:

    @Entity
    public class BORROWER {
    
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private long id;
    
        @Embedded
        protected BORROWER_DETAIL borrower_DETAIL;
    
    
    
        @Embedded
        protected NAME name;
    
    
        @ManyToOne
        protected DEAL deal;
    
    
        //Mark transient to force orika to skip
        @Transient
        public DEAL getDeal() {
            return deal;
        }
    
        public void setDeal(DEAL deal) {
            this.deal = deal;
        }
    
        public BORROWER_DETAIL getBorrower_DETAIL() {
            return borrower_DETAIL;
        }
    
        public void setBorrower_DETAIL(BORROWER_DETAIL borrower_DETAIL) {
            this.borrower_DETAIL = borrower_DETAIL;
        }
    
        public NAME getName() {
            return name;
        }
    
        public void setName(NAME name) {
            this.name = name;
        }
    
        public long getId() {
            return id;
        }
    
        public void setId(long id) {
            this.id = id;
        }
    }