dev

J2EE - JPA

/wrote/note/dev/j2ee/jpa/

J2EE - JPA

Problems

Mismatches between relational and object models

What is JPA

Java Persistence API is a collection of classes and methods (interfaces/specification) to persistently store the vast amounts of data into a database which is provided by the Oracle Corporation.

JPA shows how to define a Plain Oriented Java Object (POJO) as an entity and how to manage entities with relations.

jpa_arch jpa_api

JPA Provider

  • Hibernate
  • Eclipselink
  • Toplink

Difference between JPA and Hibernate

  • JPA is just a specification, meaning there is no implementation. Hibernate is the Hibernate’s JPA implementation.
  • JPA tells you how to dance, Hibernate is the dancer.

ORM Architecture

three phase: Object data -> Mapping -> Relational data

jpa_orm

Spring JPA Example