SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
128 stars 80 forks source link

$expand not working properly #350

Open Nismath opened 4 months ago

Nismath commented 4 months ago

Hello @wog48 , I am having an issue with the $expand query. It is giving the following error:

"message": "The attribute [maskedAttribute] is not present in the managed type [EntityTypeImpl@randomHashCode:MaskedEntity [ javaType: class com.example.model.MaskedEntity descriptor: RelationalDescriptor(com.example.model.MaskedEntity --> [DatabaseTable(MASKED_TABLE)]), mappings: 12]]."

I'm using orable Database and the following dependencies

<processor.version>2.1.3</processor.version>
        <java.version>17</java.version>
        <build.sourceEncoding>UTF-8</build.sourceEncoding>
        <eclipselink.version>4.0.3</eclipselink.version>
        <jpa.version>3.1.0</jpa.version>

my main entity having a relationship


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MASKED_ATTRIBUTE")
public MaskedType getMaskedType() {
    return this.maskedType;
}

I'm trying to expand the http://localhost:9010/Trippin/v1/MaskedEntity(-8)?$expand=MaskedType

in metadata I'm missing ReferentialConstraint for the navigation property. when i dedugged into the source file. com.sap.olingo.jpa.metadata.core.edm.mapper.impl class IntermediateModelElement method

 private Optional<CsdlReferentialConstraint> determineReferentialConstraint(
      final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException, ODataJPAModelIgnoreException

line sourceType.getPropertyByDBField(intermediateColumn.getName()); is getting null. if the join column field is not in the current class