Nikolay Grechanov created OLINGO-1243:
-----------------------------------------

             Summary: Updating foreign key properties has no effect
                 Key: OLINGO-1243
                 URL: https://issues.apache.org/jira/browse/OLINGO-1243
             Project: Olingo
          Issue Type: Bug
    Affects Versions: V2 2.0.10, V2 2.0.8
         Environment: Java EE 7 (TomEE) Server, Java 8, EclipseLInk 2.5.2
            Reporter: Nikolay Grechanov


In my JPA model I have Child entity which has Parent property:
{code:java}
@ManyToOne(fetch = EAGER, optional = false)
@BatchFetch(JOIN)
@NotNull
@JoinColumn(name = "PARENT_ID", nullable = false)
private Parent parent;{code}
$metadata contains Parent property as well as referential constraint for 
association:
 
{code:java}
...
<EntityType Name="Child">
 <Key>
  <PropertyRef Name="Id"/>
 </Key>
 <Property Name="Parent" Type="Edm.Int64" Nullable="false"/>
 <NavigationProperty Name="ParentDetails" 
Relationship="myProject.Child_Parent_Many_One0" FromRole="Child" 
ToRole="Parent"/>
</EntityType>
...
<Association Name="Child_Parent_Many_One0">   <End Type="myProject.Child" 
Multiplicity="*" Role="Child"/>  <End Type="myProject.Parent" Multiplicity="1" 
Role="Parent"/>  <ReferentialConstraint>
  <Principal Role="Parent">
   <PropertyRef Name="Id"/>
  </Principal>
  <Dependent Role="Child">
   <PropertyRef Name="Parent"/> 
  </Dependent> 
 </ReferentialConstraint> 
</Association> 
...{code}
Imagine I have Child with id = 1 and Parent with id = 2

If I want to change Child's Parent from 2 to 3 I call:
{code:java}
PUT /Children(1) {"Parent":"3"}{code}
As the result, I get HTTP 204 No Content, but the request has absolutely no 
effect on Child entity: if I GET it again the Parent property will have old 
value 2 and the Navigation property will point to the old Parent as well.

For the time being I make the following call to edit Navigation properties:
{code:java}
PUT /Children(1) {"ParentDetails":{"__deferred":{ "uri":"/Parents(3L)"}}}{code}
But I would like to be able to do the same by updating Parent property: it's 
much easier and it is also the only way supported by SAPUI5 library that I use 
in UI development.

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to