Chapter 3. Entities

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics:

  • EJB 3 entities

  • Java persistence API

  • Mapping an entity to a database table

  • Metadata defaults

  • Introduction to the entity manager

  • Packaging and deploying entities

  • Generating primary keys

  • Overriding metadata defaults

Introduction

Entities are classes that need to be persisted; their state is stored outside the application, typically in a relational database. Unlike session beans, entities do not have business logic other than validation. As well as storing such entities, we want to query, update, and delete them.

The EJB 3 specification recognizes that many applications have the above persistence ...

Get EJB 3 Developer Guide 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.