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

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
主站蜘蛛池模板: 增城市| 万全县| 镶黄旗| 边坝县| 罗平县| 江达县| 泰来县| 揭阳市| 舟曲县| 广河县| 博客| 望江县| 抚顺市| 安仁县| 漯河市| 策勒县| 诏安县| 彰武县| 富阳市| 金寨县| 肇源县| 姜堰市| 乐平市| 延庆县| 民和| 冕宁县| 南澳县| 个旧市| 泽库县| 双流县| 大庆市| 晋州市| 兴宁市| 仁化县| 桃源县| 南城县| 吐鲁番市| 远安县| 微山县| 南丰县| 高雄市|