Chapter 3. Database persistence with entities
This chapter covers
In the last chapter, we discussed Spring Roo from a developer’s perspective. We discussed the various component types, and how the Roo shell creates and maintains objects in your projects, hiding tedious, repetitive code behind AspectJdriven.aj files.
In this chapter, you’ll learn how to store and load data from relational databases. You’ll start by defining object-relational mapping (ORM) APIs and the standard Java Persistence API, and then learn how to configure persistence in a project using the Roo shell. Next, you’ll define Roo entities, which are an enhanced version of the standard JPA Entity class. You’ll create entity components in the shell, and we’ll show you how to load, persist, and remove them, using Roo’s JUnit-based integration test framework.
Next, you’ll use the Bean Validation Framework to configure automatic data validation in your entities. We’ll discuss both built-in and custom validations, and how to provide validation messages. We’ll discuss finders—methods that allow for searching for properties within a Roo entity. We’ll wrap up by discussing JPA Repositories.