cancel
Showing results for 
Search instead for 
Did you mean: 

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

jonaswang
Advisor
Advisor
0 Kudos

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");
}
MKM
Active Participant
0 Kudos

Hi Jonas,

Got any solution for this. I am facing the same issue.

Thanks,

Manoj

Accepted Solutions (0)

Answers (1)

Answers (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

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

jonaswang
Advisor
Advisor
0 Kudos

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.

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

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

Regards,
Ivan

jonaswang
Advisor
Advisor
0 Kudos

Hi Ivan,

I sent you an email with the artifacts. Thanks!

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Jonas,

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

Regards,
Ivan