Relationship operations

OData supports the linking of related resources. Relationships from one entity to another are represented as navigation properties. The following API reads employees in the HR department:

http://localhost:8080/hrapp/odata/Departments("HR")/
EmployeeDetails

The OData service even allows you to add, update, and remove a relation via navigation properties. The following example shows how you can use the navigation properties to link the employee with the id value of 1700 to the IT department:

POST odata/Departments('IT')/Employees/$ref 
OData-Version: 4.0 
Content-Type: application/json;odata.metadata=minimal 
Accept: application/json 
{ 
  "@odata.id": "odata/Employees(1700)" 
} 
Many API vendors have started considering OData for standardizing their REST APIs, particularly with the release of OData Version 4.0. A detailed discussion of OData is beyond the scope of this book. To learn more about OData, visit the official documentation page available at http://www.odata.org/documentation.

To learn how to transform the Java Persistence API (JPA) entities into OData REST APIs, refer to the Transforming the JPA model into OData-enabled RESTful web services section in the Appendix, Useful Features and Techniques, of this book.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.119.81