Choosing a strategy to expose JPA Entities

The content object(s) exposed in resources are JPA Entities. The interesting point about wrapping a JPA Entity in a resource comes with the low-level nature of an Entity itself, which supposedly represents a restricted identifiable domain area. This definition should ideally be entirely translated to the exposed REST resources.

So, how do we represent an Entity in REST HATEOAS? How do we safely and uniformly represent the JPA associations?

This recipe presents a simple and conservative method to answer these questions.

How to do it…

  1. We have presented one entity used as a resource (Index.java). Here is another entity that is used: Exchange.java. This entity presents a similar strategy to expose its JPA associations: ...

Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.