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.

OData Key Specification<br />

The OData specification requires an EntityType to denote a set properties forming a unique key. In <strong>HANA</strong> only<br />

tables may have a unique key, the primary key. For all other (mostly view) objects you need to specify a key for the<br />

entity. In OSDL you can do this by denoting a set of existing columns or by generating a key.<br />

For the examples illustrating key specification, we use the following SQL view, which selects all data from the<br />

specified table.<br />

View definition sample.odata:view.hdbview<br />

{<br />

}<br />

"name": "view",<br />

"schema": "ODATASAMPLES",<br />

"query": "SELECT * FROM \"ODATASAMPLES\".\"sample.odata::table\""<br />

Existing Key Properties<br />

If the object has set of columns that may form a unique key, you can specify them as key for the entity. These key<br />

properties are always selected from the database, no matter if they are omitted in the $select query option.<br />

Therefore explicit keys are not suitable for calculation views and analytic views as the selection has an impact on<br />

the result.<br />

Service definition sample.odata:explicitkeys.xsodata/$metadata<br />

service {<br />

"sample.odata:view.hdbview" as "MyView" keys ("ID","Text");<br />

}<br />

The created metadata document for the exposure of the view above is almost equal to the metadata document for<br />

repository objects. Only the key is different and consists now of two columns:<br />

http://localhost:8002/sample/odata/explicitkeys.xsodata/$metadata<br />

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

Defining Web-based Data Access<br />

P U B L I C<br />

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

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

Saved successfully!

Ooh no, something went wrong!