Spring Data JPA introduction and presentation

Chapter 1 Overview 1.ORM [understand]

  ORM (Object-Relational Mapping) represents an object-relational mapping. In object-oriented software development by ORM, you can put objects mapped to a relational database. As long as a set of procedures can do to associate objects with the database, the operation object can directly manipulate database data, we can say that this program implements object-relational mapping ORM

  Simply put: ORM is to establish the relationship between the entity classes and database tables, so as to achieve the purpose of operating the entity class is equivalent to the operation of the database table.

1.1 Why use ORM

  When implementing an application (without using the O / R Mapping), we may write code in particular multiple data access layer, the data from the database to save, modify data, delete data, and these codes are repetitive. The use of ORM will greatly reduce repetitive code. Object-relational mapping (Object Relational Mapping, referred to as ORM), the main implementor of the object to relational mapping database data.

1.2 Common ORM framework

  Common orm framework: Mybatis (ibatis), Hibernate, Jpa

Chapter 2 Overview of the JPA and hibernate [understand]

2.1 hibernate Overview

  Hibernate object-relational mapping framework is an open source, it had a very lightweight JDBC object package, it will POJO mapping relationship with a database table, it is a fully automated orm framework, hibernate can automatically generate SQL statements, automatically, so that the Java programmer can use arbitrary object programming thinking to manipulate the database.

2.2 JPA Overview

  JPA stands Java Persistence API, the API Java Persistence i.e., a set is launched SUN ORM-based specification, the interior is composed of a series of abstract classes and interfaces.

  JPA through JDK 5.0 annotations that describe the object - mapping between relational tables, solid objects and run persistence to the database.

2.3 JPA advantage

1. Standardization

  JPA is one of JCP Java EE standards issued by the Organization, so any claims that meet the JPA standard frameworks follow the same structure, provide the same access API, which guarantees the development of enterprise applications based on the JPA through a small amount of modification can be able to in a different It runs under the JPA framework.

2. support vessel class features

  JPA framework to support large data sets, transactions, concurrency and other container-level services, which makes the JPA persistence beyond the limitations of simple framework, play a greater role in enterprise applications.

3. Easy

  JPA One of the main goals is to provide a simpler programming model: create entities and create a Java class in the JPA framework as easy, without any restrictions and limitations, just use javax.persistence.Entity annotate, JPA framework and interfaces also very simple and not too many special rules and requirements of design patterns, developers can easily grasp. JPA design based on the principle of non-invasive, and therefore can be easily integrated with other frame or container

4. query capabilities

  JPA query language is object-oriented rather than oriented database, which is an object-oriented structure of natural query syntax can be seen as the equivalent of Hibernate HQL. JPA defines a unique JPQL (Java Persistence Query Language), JPQL is an extension of EJB QL, which is a query language for the entity, the object is operating entity, rather than relational database table, and can support batch updates and modify, JOIN, GROUP BY, HAVING and so usually only advanced SQL query feature to be able to provide even support sub-queries.

5. Advanced Features

  JPA can support advanced object-oriented features such as inheritance between classes, the complex relationship between polymorphism and classes, such support allows developers to maximize the use of object-oriented model design enterprise applications, without the need to own deal with these characteristics persisted in a relational database.

2.4 JPA's relationship with hibernate

  JPA ORM specification is essentially a kind of norm, attention is not ORM framework - as JPA ORM implementation does not provide, it just developed a number of standards, offer programming API interface, but the concrete realization by the service vendors to provide an implementation.

  

  The relationship between JPA and Hibernate as the relationship between JDBC driver and JDBC, JPA is the norm, except as Hibernate ORM framework, it is also a JPA implementation. Hibernate JPA how to replace it? JDBC specification can drive the underlying databases? The answer is no, that is to say, if you use JPA specification database operations, the underlying need to hibernate as its implementation class for data persistence work.

 

Guess you like

Origin www.cnblogs.com/116970u/p/11579609.html