Skip to Main Content
Java EE 6 Pocket Guide
book

Java EE 6 Pocket Guide

by Arun Gupta
September 2012
Intermediate to advanced content levelIntermediate to advanced
210 pages
3h 59m
English
O'Reilly Media, Inc.
Content preview from Java EE 6 Pocket Guide

Chapter 4. Java Persistence API

The Java Persistence API (JPA) is defined as JSR 317, and the complete specification can be downloaded from http://jcp.org/aboutJava/communityprocess/final/jsr317/index.html.

JPA defines an API for the management of persistence and object/relational mapping using a Java domain model.

A database table, typically with multiple columns, stores the persistent state of an application. Multiple rows are stored in the database table to capture different states. A single column or combination of columns may define the uniqueness of each row using primary key constraint. Typically, an application accesses and stores data to multiple tables. These tables generally have relationships defined among them using foreign key constraint.

JPA defines a standard mapping between a database table and a POJO. It defines syntax to capture primary and foreign key constraints and how these rows can be created, read, updated, and deleted using these POJOs. Transactions, caching, validation, and other similar capabilities required by an application accessing a database are also defined by JPA.

This chapter will discuss the key concepts of JPA.

Entities

A POJO with a no-arg public constructor is used to define the mapping with one or more relational database tables. Each such class is annotated with @Entity, and the instance variables that follow JavaBeans-style properties represent the persistent state of the entity. The mapping between the table column and the field name is derived ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java EE 7 Essentials

Java EE 7 Essentials

Arun Gupta
Beginning Java EE 7

Beginning Java EE 7

Antonio Goncalves
The Java EE 6 Tutorial: Advanced Topics, Fourth Edition

The Java EE 6 Tutorial: Advanced Topics, Fourth Edition

Eric Jendrock, Ricardo Cervera-Navarro, Ian Evans, Devika Gollapudi, Kim Haase, William Markito, Chinmayee Srivathsa

Publisher Resources

ISBN: 9781449338329Errata