Chapter 2. Persisting Objects Using JPA

In this chapter, we will cover:

  • Setting up a JPA provider for your project
  • Viewing database configuration properties
  • Managing database configuration properties
  • Creating persistent entities
  • Adding JSR 303 constraints to persistent fields
  • Creating integration tests for persistent entities
  • Creating new 'data on demand' for testing entities
  • Creating mock tests for persistent entities
  • Executing persistent entities tests
  • Controlling auto-generated methods of persistent entities
  • Creating applications that interact with multiple databases
  • Packaging your Roo project

Introduction

Java Persistence API (JPA) provides a standard API for persisting Java objects to a relational database. The recipes in this chapter look at Roo commands that configure the data source and JPA provider (for example, Hibernate and OpenJPA), and Roo commands that create persistent entities of your enterprise application.

If you're using Spring only in the persistence layer, you'll see in this chapter how Roo can be used to quickly develop the persistence layer of your application. You'll notice that applications generated using Roo don't have a DAO (Data Access Object) layer because the domain entities generated by Roo are themselves rich in flavor, with finder and CRUD methods defined in the persistent entities. Also, Roo-generated applications don't have a service layer for abstracting business services (which in turn could access persistent entities). If you want to create a service layer for your enterprise application, it is left up to you to create services. You should create a service layer for your enterprise application if the business logic spans multiple persistent entities, if you want to put transactional boundaries in the service layer, or if you want the business logic to be contained in the service layer, and so on.

In Chapter 4, Web Application Development with Spring Web MVC and Chapter 5, Web Application Development with GWT, Flex, and Spring Web Flow we'll see that Spring Roo generates the web layer of the application, which directly interacts with the persistent entities—leaving behind service and data access layers.

..................Content has been hidden....................

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