Chapter 4. Relationships, JPA, and advanced persistence

 

This chapter covers

  • Object relations
  • Defining entity relationships
  • Reverse engineering JPA entities
  • Adding a service layer
  • Using JPA directly
  • NoSQL databases with MongoDB

In chapter 3, we discussed how to install Roo’s JPA-based persistence engine, create entities, and manipulate them using Roo’s domain-driven entity ITD methods such as persist(), find(), and merge(). You saw how to validate entities using the Bean Validation API and how to generate search queries using the finder facility. You also saw how to build Spring-based repositories so that developers who want a separation of application layers can still provide a data layer for their applications.

In this chapter, you’ll learn how to relate entities to each other, building JPA relationships via the Roo shell. You’ll use the field reference and field set commands, which establish JPA relationships via various annotations, collections, and references. You’ll explore several mapping strategies, including one-to-many, many-to-many, many-to-one, and inheritance hierarchies. You’ll see how to use the reverse engineering facility to automatically create entities from an existing database. You’ll then see how to build Spring-based services to expose the repositories and to create a traditional, layered, service-based architecture.

Let’s begin by reviewing how JPA manages relationships between database entities.

4.1. Object relations: it’s all relative

 
 

4.2. A sample Course Manager database

 
 
 

4.3. Course Manager relationships

 
 
 
 

4.4. Reverse engineering your database

 

4.5. Adding a service layer

 
 

4.6. Using JPA directly

 
 
 

4.7. NoSQL databases with MongoDB

 
 
 
 

4.8. Summary

 
 

4.9. Resources

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage