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

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
主站蜘蛛池模板: 工布江达县| 灵川县| 丁青县| 上犹县| 崇左市| 新乡县| 乐清市| 北海市| 简阳市| 兴安县| 漳州市| 南城县| 泰来县| 德安县| 抚顺县| 牙克石市| 海城市| 苍梧县| 图木舒克市| 称多县| 县级市| 华蓥市| 龙井市| 金塔县| 洛扎县| 玛纳斯县| 凌云县| 大埔县| 包头市| 新宁县| 马尔康县| 武汉市| 鄱阳县| 镇沅| 宜春市| 隆昌县| 保亭| 乌兰浩特市| 高雄县| 望都县| 嵩明县|