SAP CAP - Select OData Entity With Primary Keys

606 views Asked by At

We have the following URL that leads to the desired result (executed in gw client):

//xyz.com/myEntity(key1='12345',key2=datetime'2022-02-01')/Results

I have now imported this OData API into my Java project via CDS import and am trying to recreate this query.

The OData Model looks in principle like this:

entity myEntity {
  key key1 : String;
  key key2 : Date;
  Results : Association to many mySecondEnity;
}

My select looks like:

SELECT.from(MyService_.CDS_NAME).columns(c -> c.Results().expand(...)).where(w -> w.key1().eq('12345').and().key2(...);

Our problem now is that this Where condition is of course implemented as $filter. But we have to address the entity via keys to get the results. And that without expand.

The resulting URL looks like this:

//xyz.com/myEntity?$filter=key eq '123' etc.

Is this possible in the Java SDK to have the URL look like described in the beginning?

Or do I have to build a HTTP client myself?

0

There are 0 answers