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

Chandan V.A commented on OLINGO-770:
------------------------------------

Hello Miguel,
Can you please attach the Atom XML that is getting passed to Server.
I suspect the content of the Atom XML. The error "Cannot match segment" will 
come provided the link tags are not correctly passed to the JPA processor.

Example: JPA processor uses contents of link tag to link two different 
entities. For this the link tag should look as shown below

<link href=<TargetEntitySet>(<Key>) 
rel=http://schemas.microsoft.com/ado/2007/08/dataservices/related/<Navigation 
Properties> .... >

However if the atom xml contains links tags as shown below
<link href=<StartEntitySet>(<Key>)/<Navigation Property>   
rel=http://schemas.microsoft.com/ado/2007/08/dataservices/related/<Navigation 
Properties> .... > 

then JPA processor will throw an error because this link information cannot be 
used for linking two entities as per OData specification. I guess this link is 
getting generated by your client code and added to the Atom XML. Try removing 
this link tag from Atom XML and the request should go through without any 
exception.

The link 
<link href=<StartEntitySet>(<Key>)/<Navigation Property>   
rel=http://schemas.microsoft.com/ado/2007/08/dataservices/related/<Navigation 
Properties> .... >  is needed only if you are trying to execute a deep insert. 
An inline entry/feed can be passed under such link tag.

I hope this clarifies your query.

Regards
Chandan

> JPA OneToMany not able to create entity
> ---------------------------------------
>
>                 Key: OLINGO-770
>                 URL: https://issues.apache.org/jira/browse/OLINGO-770
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.4
>            Reporter: Miguel
>            Assignee: Chandan V.A
>
> I have 2 entities OrderHeader and OrderItem,, the relation between then is 
> One To Many... with bi-directional
> In the OrderHeader 
> @OneToMany(mappedBy="OrderHeader")
> private List<OrderItem> orderItems;
> In the OrderItem 
> @ManyToOne(fetch=FetchType.LAZY)
> @JoinColumn(name="ORDER_ID", nullable=false)
> private OrderHeader orderHeader;
> When the following is called
> ODataEntry entry = template.requestBody("olingo2://create/OrderHeaders", 
> body, ODataEntry.class);
> There is a exception thrown
> Could not match segment: 'OrderHeaders(4004280407L)/OrderItemDetails'.



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

Reply via email to