O'Reilly logo

Spring MVC Cookbook by Alex Bretet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required