cancel
Showing results for 
Search instead for 
Did you mean: 

Query single entity with @sap/cds-odata-v2-adapter-proxy

c-held
Explorer

Dear experts,

we are using @sap/cds-odata-v2-adapter-proxy in our service and when querying a single composition-entry, we get back all of them.

The schema.cds of our BusinessPartnersService looks roughly like this.

project/businesspartner/db/schema.cds:

using {
    common.Addresses
} from '@common';

entity BusinessPartners : managed, cuid {
    someProperties      : String;
    addresses           : Composition of many Addresses
                          on addresses.parent = $self.ID;
}

We explicitly expose the Addresses in the service.cds since we want to allow updates on them.

project/businesspartner/srv/businesspartners-service.cds:

using {common.Addresses} from '@common';


service BusinessPartnersService {
    entity BusinessPartners        as projection on my.BusinessPartners 
    entity common.Addresses        as projection on Addresses;
}

The schema for the addresses is imported from our common package. It basically looks like this.

project/common/db/schema.cds:

namespace common;

@cds.persistence.skip : 'if-unused'
entity Addresses : managed, cuid {
    parent                : UUID;
    someAddressProperties : String;
}

If we now start the service locally and try to query a single address directly via

http://localhost:4004/v2/business-partners/common_Addresses(guid'<guid-of-the-address>')

the service responds with the list of all addresses, the same result when querying

http://localhost:4005/v2/business-partners/common_Addresses.

The same result occurs for other syntax, such as

  • .../common_Addresses(<guid-of-the-address>)
  • .../common_Addresses('<guid-of-the-address>')
  • .../common_Addresses(ID='<guid-of-the-address>')

Strangely, the v4 service behaves as expected. We get the specified single entry with

http://localhost:4005/business-partners/common_Addresses(guid'<guid-of-the-address>').

Do you have an idea why we can not access single address entries like this ?

Thank you very much in advance

Christoph

View Entire Topic
0 Kudos

Hi Christoph,

Have you tried with .../common_Addresses?$filter=id eq '<guid-of-the-address>'

Thanks,

Sudhi