Relations Sprng Data JPA and hibernate in

1.ORM Overview

 

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 ORM Object Relational Mapping

 

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

 

2.hibernate and JPA Overview [ understand ]

 

2.1  Hibernate Overview

 

Hibernate is an object-relational mapping framework for an open source, its JDBC had a very lightweight object package, it will POJO mapping relationship with a database table, 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 the API , i.e. Java persistence the API , a SUN launched based on a set of ORM specification, the interior is composed of a series of abstract classes and interfaces.

 

JPA through JDK 5.0 Description Object Notation - mapping between relational tables, solid objects and run persistence to the database.

 

1.1  JPA advantage

 

1. Standardization

 

   JPA is the JCP organization released the Java EE standard one, so any claims that meet the JPA standard frameworks follow the same structure, provide the same access API , which guarantees based on JPA development of enterprise applications to pass a small amount of modification can be in different the JPA run frame.

 

2. support vessel class features

 

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

 

3. Easy

 

   JPA One of the main goals is to provide a simpler programming model: the JPA to create an entity created under the framework and Java class is as simple, 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 Hibernate HQL equivalent. JPA defines a unique JPQL ( the Java Persistence Query Language ), JPQL is EJB QL an extension, 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 , the GROUP BY , the HAVING and so usually only SQL advanced 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 and hibernate relations

 

JPA specification is essentially a kind of ORM specification, attention is not ORM framework - because JPA does not provide ORM achieve, it just developed a number of standards, provides some programming API interface, but the specific implementation provided by the service vendors to implement. 

 

 

 

 

Guess you like

Origin www.cnblogs.com/yangzhixue/p/12348508.html