cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP Compositon used by two different root entities

former_member729305
Participant

Dear community,

within our CAP model we intend to have an assignment table which can be maintained by two different root entities as follows:

db reference model:

entity PARTY {
    key ID           : UUID;
        NAME : String;

        PARTY_PEOPLE : Composition of many PARTY_PEOPLE
                           on  PARTY_PEOPLE.PARTY = $self;
                         
}


entity PARTY_PEOPLE {
    ID        : UUID;
    PERSON_ID : UUID;
    PERSON: Association to PERSON: 
                       on PERSON.ID = PERSON_ID;
    key PARTY: Association to PARTY;
    key EVENT: Association to EVENT;
                        
}


entity PERSON {
    key ID   : UUID;
        NAME : String;
}


entity EVENT{
    key ID           : UUID;
      NAME : String;
      PARTY_PEOPLE : Composition of many PARTY_PEOPLE
                           on  PARTY_PEOPLE.EVENT = $self;
                           
}
service.cds:
@path     : '/test'
service TestService {
    @odata.draft.enabled
    entity PARTY             as projection on TEST.PARTY;
    entity PARTY_PEOPLE as projection on TEST.PARTY_PEOPLE;
    @odata.draft.enabled
    entity EVENT             as projection on TEST.EVENT;
}
by testing this the CAP always throws the following error:[ERROR] srv/service.cds:9:12: Entity “TestService.PARTY_PEOPLE.drafts” already generated by draft root "TestService.PARTY" (in entity:"TestService.EVENT")
in this matter we assume it is not possible to have a composition of the same assignment table(PARTY_PEOPLE) by two different root entities as long as both are @odata.draft.enabled, correct? if not, what could be a possible solution?Best Regards
patricebender
Product and Topic Expert
Product and Topic Expert

Hi Max,

thanks for bringing this up. We from the cds-compiler team will look into this.

From a modelling perspective, two draft roots could share the `PARTY_PEOPLE.drafts` Table.

However, we are not yet sure how the runtimes would handle this situation. We will discuss this internally and get back to you soon 🙂

BR,

Patrice

Max_xii
Explorer
0 Kudos

Hello patricetao ,

any update on this?
I have the same problem.

regards Maxi

rui_zhang1
Explorer
0 Kudos

weeklyReports : Association to many Opp2WeeklyReport

Hi,  @snarkway , you can use "Association to many PARTY_PEOPLE"  to instand of "Composition of many PARTY_PEOPLE"

Accepted Solutions (0)

Answers (0)