Skip to Content
0

How to Create Many-to-Many Relationship Association in xsodata

Apr 11 at 06:39 PM

65

avatar image

Hi experts,

I have a Technology table and a Project table. The relationship between two of them are many-to-many. A project can used multiple technologies and a technology can be used in different projects. Thus I also have a relationship table Project_Technology. Its primary keys are PId and TId. I created a xsodata file to expose the data. However I'm getting syntax error on the association. Any thoughts would be helpful.

service {
    "PROJECT_EXPLORER"."Technology" as "Technologies";
    "PROJECT_EXPLORER"."Project" as "Projects" navigates ("Projects_Technologies" as "Has");
    association "Projects_Technologies" with referential constraint principal "Projects"("Id") multiplicity "*" dependent "Technologies"("Id") multiplicity "*" 
        over "PROJECT_EXPLORER"."Project_Technology" principal ("PId") dependent ("TId");
}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ivan Mirisola
Apr 11 at 07:17 PM
1

Hi

Are you doing this on XSC or XSA?

Here is a sample from the Hana Developer Guide that is know to work:

service {
 "sample.odata::customer" as "Customers";
 "sample.odata::order" as "Orders";
 association "Customer_Orders"
 principal "Customers"("ID") multiplicity "*"
 dependent "Customers"("ID") multiplicity "*"
 over "sample.odata::knows" principal ("KnowingCustomerID") dependent ("KnownCustomerID");
} 

Main differences are: no navigates clause and the table name references using colon notation.

Have you tried removing the navigates clause? And what about the table names?

Regards,
Ivan

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Ivan,

I'm doing this on XSA.

I actually looked into this example from the documentation. This example defines a many-to-many association with two same entities. But I am trying to define an association between two different entities. And associations need to be bound to entities by a NavigationProperty.

0

Hi,

Could you share the cds artifact so I can try to discover a solution to your problem?

Regards,
Ivan

0

Hi Ivan,

I sent you an email with the artifacts. Thanks!

0

Hi Jonas,

Apparently you need to use the repository names instead of catalog names in your xsodata. Is that correct?

Regards,
Ivan

0