JPA - Architecture
2015-09-02 07:30
393 查看
Java Persistence API is a source to store business entities as relational entities. It shows how to define a Plain Oriented Java Object (POJO) as an entity and how to manage entities with relations.
The following table describes each of the units shown in the above architecture.
The above classes and interfaces are used for storing entities into a database as a record. They help programmers by reducing their efforts to write codes for storing data into a database so that they can concentrate on more important activities such as writing codes for mapping the classes with database tables.
The relationship between EntityManagerFactory and EntityManager is one-to-many. It is a factory class to EntityManager instances.
The relationship between EntityManager and EntityTransaction is one-to-one. For each EntityManager operation, there is an EntityTransaction instance.
The relationship between EntityManager and Query is one-to-many. Many number of queries can execute using one EntityManager instance.
The relationship between EntityManager and Entity is one-to-many. One EntityManager instance can manage multiple Entities.
Class Level Architecture
The following image shows the class level architecture of JPA. It shows the core classes and interfaces of JPA.The following table describes each of the units shown in the above architecture.
Units | Description |
---|---|
EntityManagerFactory | This is a factory class of EntityManager. It creates and manages multiple EntityManager instances. |
EntityManager | It is an Interface, it manages the persistence operations on objects. It works like factory for Query instance. |
Entity | Entities are the persistence objects, stores as records in the database. |
EntityTransaction | It has one-to-one relationship with EntityManager. For each EntityManager, operations are maintained by EntityTransaction class. |
Persistence | This class contain static methods to obtain EntityManagerFactory instance. |
Query | This interface is implemented by each JPA vendor to obtain relational objects that meet the criteria. |
JPA Class Relationships
In the above architecture, the relations between the classes and interfaces belong to thejavax.persistencepackage. The following diagram shows the relationship between them.
The relationship between EntityManagerFactory and EntityManager is one-to-many. It is a factory class to EntityManager instances.
The relationship between EntityManager and EntityTransaction is one-to-one. For each EntityManager operation, there is an EntityTransaction instance.
The relationship between EntityManager and Query is one-to-many. Many number of queries can execute using one EntityManager instance.
The relationship between EntityManager and Entity is one-to-many. One EntityManager instance can manage multiple Entities.
相关文章推荐
- 如何让特定的命令不保存在eshell history中
- /etc/fstab 参数详解及如何设置开机自动挂载
- *Rectangle Area
- [Leetcode]#92 Reverse Linked List II
- Linux 查看系统硬件信息(实例详解)
- [Leetcode]#88 Merge Sorted Array
- Linux 查看系统硬件信息(实例详解)
- Linux下添加新硬盘,分区及挂载
- Linux下添加新硬盘,分区及挂载
- Spring笔记――10.两种后处理器
- [Leetcode]#86 Partition List
- 🍊
- [Leetcode]#83 Remove Duplicates from Sorted List
- [Leetcode]#82 Remove Duplicates from Sorted List II
- JPA - Introduction
- [Leetcode]#78 Subsets
- [Leetcode]#74 Search a 2D Matrix
- [Leetcode]#69 Sqrt(x)
- 看这些孩子在 Ubuntu 的 Linux 终端下玩耍
- [Leetcode]#67 Add Binary