CHAPTER 2

image

Basic Mapping and Object Identity

A primary key in a database table is used to uniquely identify a record in that table. The primary key value can’t be null and is unique within a table. The primary key is also used to establish a relationship between two tables; it is defined as a foreign key in the associated table. Because the primary key is used to identify a particular record, it can also be called the database identifier, which is exposed to the application by Hibernate through an identifier property of the persistent entity. This chapter discusses the various ways to generate an identifier (primary key) for a database record. ...

Get Hibernate Recipes: A Problem-Solution Approach, Second Edition 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.