You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Chandan V.A (JIRA)" <ji...@apache.org> on 2013/11/01 16:11:17 UTC

[jira] [Comment Edited] (OLINGO-45) ClassCastException on Entity update

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

Chandan V.A edited comment on OLINGO-45 at 11/1/13 3:09 PM:
------------------------------------------------------------

Did you try $links option to update relations between two different entities.

Below example Links a SalesOrderLineItem with SalesOrderHeader

HTTP PUT - http://localhost:8080/olingo.odata2.jpa.processor.ref.web/SalesOrderProcessing.svc/SalesOrderLineItems(LiId=24L,SoId=22L)/$links/SalesOrderHeaderDetails

Content 
<?xml version="1.0" encoding="UTF-8"?>
<uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">http://localhost:8080/olingo.odata2.jpa.processor.ref.web/SalesOrderProcessing.svc/SalesOrders(22L)</uri>

I will also check the custom X-HTTP-Method (MERGE). 


was (Author: chandan.v.a):
Did you try $links option to update relations between two different entities.

Below example Links a SalesOrderLineItem with SalesOrderHeader

HTTP PUT - http://localhost:8080/olingo.odata2.jpa.processor.ref.web/SalesOrderProcessing.svc/SalesOrderLineItems(X=3,LiId=24L,SoId=22L)/$links/SalesOrderHeaderDetails

Content 
<?xml version="1.0" encoding="UTF-8"?>
<uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">http://localhost:8080/olingo.odata2.jpa.processor.ref.web/SalesOrderProcessing.svc/SalesOrders(22L)</uri>

I will also check the custom X-HTTP-Method (MERGE). 

> ClassCastException on Entity update
> -----------------------------------
>
>                 Key: OLINGO-45
>                 URL: https://issues.apache.org/jira/browse/OLINGO-45
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: 1.0.0, 1.1.0
>            Reporter: Georgi
>            Assignee: Chandan V.A
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.1#6144)