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

Property and referential constraint are missing when @ManyToOne(fetch = EAGER)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • V2 2.0.10
    • None
    • odata2-jpa
    • Java EE 7 (TomEE) Server, Java 8, EclipseLink 2.5.2

    Description

      In my JPA model I have the following property:

      @ManyToOne(fetch = EAGER, optional = false)
      @BatchFetch(JOIN)
      @NotNull
      @JoinColumn(name = "PARENT_ID", nullable = false)
      @JsonProperty(PARENT_DETAILS)
      @JsonSerialize(using = ODataDeferredSerializer.class)
      private Parent parent;

      $metadata contains Parent property as well as referential constraint for association:
       

      ...
      <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> 
      ...

      When I set 

      @ManyToOne(fetch = LAZY, optional = false)

       

      then $metadata contains neither Parent property nor referential constraint for the association:

      ...
      <EntityType Name="Child">
       <Key>
        <PropertyRef Name="Id"/>
       </Key>
       <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"/>
      </Association> 
      ...

      ManyToOne.optional, NonNull, JoinColumn.nullable annotation values have no effect

      Attachments

        Activity

          People

            Unassigned Unassigned
            .det Nikolay Grechanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: