02 JPA

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.

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. supports container-level properties
       JPA-enabled framework of 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
      One of the main goals of the JPA 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 the framework and interface is also very simple, 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.
   

      The advanced features of
    JPA can support advanced object-oriented features such as inheritance between classes, the complex relationship between polymorphism and classes, such support can make an object-oriented model design enterprise application developers to maximize the use, these features without the need for discretion in a relational database persistence.

 

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/zhaochengf/p/12127398.html