Skip to Content
3
May 30, 2022 at 07:28 AM

SAP CAP Compositon used by two different root entities

581 Views

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