Chapter 4. Mapping persistent classes

 

In this chapter

  • Understanding entities and value type concepts
  • Mapping entity classes with identity
  • Controlling entity-level mapping options

This chapter presents some fundamental mapping options and explains how to map entity classes to SQL tables. We show and discuss how you can handle database identity and primary keys, and how you can use various other metadata settings to customize how Hibernate loads and stores instances of your domain model classes. All mapping examples use JPA annotations. First, though, we define the essential distinction between entities and value types, and explain how you should approach the object/relational mapping of your domain model.

4.1. Understanding entities and value types

4.1.1. Fine-grained domain models

4.1.2. Defining application concepts

4.1.3. Distinguishing entities and value types

4.2. Mapping entities with identity

4.2.1. Understanding Java identity and equality

4.2.2. A first entity class and mapping

4.2.3. Selecting a primary key

4.2.4. Configuring key generators

4.2.5. Identifier generator strategies

4.3. Entity-mapping options

4.3.1. Controlling names

4.3.2. Dynamic SQL generation

4.3.3. Making an entity immutable

4.3.4. Mapping an entity to a subselect

4.4. Summary

sitemap