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

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
主站蜘蛛池模板: 黑河市| 平昌县| 延吉市| 南平市| 建湖县| 迭部县| 双峰县| 沙雅县| 北碚区| 马龙县| 广灵县| 内乡县| 丰宁| 民乐县| 涪陵区| 乡城县| 达尔| 庆城县| 温州市| 彝良县| 肥乡县| 大冶市| 枣强县| 高平市| 定边县| 天气| 星座| 汤阴县| 瑞丽市| 平乡县| 灵武市| 临沭县| 上杭县| 肇源县| 瑞昌市| 封丘县| 喀什市| 盘山县| 南郑县| 晋州市| 来宾市|