官术网_书友最值得收藏!

Accessing the Database with JPA 2.1

The data access layer is the most fundamental part and the backbone of any enterprise application. The ultimate goal of any enterprise solution is to store and retrieve its data with respect to consistency, availability, and performance. A common problem arises when dealing with a relational database from an object-oriented system. All runtime data is represented as objects, where the real data is stored as rows in tables. When trying to save an object state into a row in a database table, or fetching some data from the database and wrapping the result back into an object again, a set of redundant programmatic statements should be written, which is very boring and actually old-school.

Object-to-relational mapping is a very common approach to overcoming this redundancy by providing a layer above the database access APIs, allowing developers to directly store and retrieve objects, and mapping their attributes directly to database tables and vice versa, providing a virtual object-oriented database interface for the actual relational data.

The Java Persistence API (JPA) does a great job at this by providing Java developers with all the required operations, mappings, and techniques for mapping objects into the relational database. In this chapter, we are going to learn how to use JPA for the following:

  • Creating and using JPA entities
  • Mapping entities to tables and columns
  • Performing CRUD operations
  • Mapping entity relationships
  • Using the JPA query language and criteria APIs
  • Mapping inheritance relationships
主站蜘蛛池模板: 铜川市| 汶川县| 个旧市| 子洲县| 津市市| 南昌市| 留坝县| 德江县| 清涧县| 缙云县| 洪泽县| 富裕县| 博爱县| 威宁| 天镇县| 鱼台县| 剑河县| 泽州县| 明溪县| 合川市| 黎平县| 山东省| 赫章县| 新龙县| 曲沃县| 广德县| 神池县| 商水县| 三穗县| 崇礼县| 蒲江县| 元氏县| 闵行区| 乾安县| 九台市| 贵港市| 江门市| 农安县| 乡宁县| 光泽县| 牙克石市|