28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

];<br />

table.primaryKey.pkcolumns = ["KnowingCustomerID","KnownCustomerID"];<br />

Relationships that are stored in association tables such as knows can be similarly defined as simple associations.<br />

Use the keyword over to specify the additional table and any required columns.<br />

Service definition: sample.odata:assoccomplex.xsodata<br />

service {<br />

"sample.odata:customer.hdbtable" as "Customers";<br />

"sample.odata:order.hdbtable" as "Orders";<br />

association "Customer_Orders"<br />

principal "Customers"("ID") multiplicity "*"<br />

dependent "Customers"("ID") multiplicity "*"<br />

over "sample.odata:knows.hdbtable" principal ("KnowingCustomerID")<br />

dependent ("KnownCustomerID");<br />

}<br />

With the keywords principal and dependent after over you can specify which columns from the<br />

association table are joined with the principal respectively dependent columns of the related entities. The<br />

number of columns must be equal in pairs, and their order in the list is important.<br />

The generated Association in the metadata document is similar to the one created for a simple association<br />

except that the ReferentialConstraint is missing:<br />

tp://localhost:8002/sample/odata/assoccomplex.xsodata/$metadata<br />

Navigation Properties<br />

By only defining an association, it is not possible to navigate from one entity to another. Associations need to be<br />

bound to entities by an NavigationProperty. You can create them by using the keyword navigates:<br />

Service definition: sample.odata:assocnav.xsodata<br />

service {<br />

"sample.odata:customer.hdbtable" as "Customers" navigates<br />

("Customer_Orders" as "HisOrders");<br />

"sample.odata:order.hdbtable" as "Orders";<br />

association "Customer_Orders" principal "Customers"("ID") multiplicity<br />

198<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Defining Web-based Data Access

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!