In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the relationship between hibernate,jpa and spring data jpa, I hope you will gain something after reading this article, let's discuss it together!
Text description
Hibernate
Hibernate is an open source object-relational mapping framework, which encapsulates JDBC with very lightweight objects. It establishes a mapping relationship between POJO and database tables, and is a fully automatic orm framework. Hibernate can automatically generate SQL statements and execute them automatically, so that Java programmers can use object programming thinking to manipulate the database at will.
JPA
JPA, whose full name is Java Persistence API, or java persistence API, is a set of ORM-based specifications issued by sun, which is composed of a series of interfaces and abstract classes.
The relationship between JPA and Hibetnate
The relationship between JPA and Hibernate is like the relationship between JDBC and JDBC drivers. JPA is the specification, and Hibernate is not only an ORM framework, but also a JPA implementation. How does JPA replace Hibernate? Can the JDBC specification drive the underlying database? The answer is no, that is, if you use the JPA specification for database operations, the underlying need for hibernate as its implementation class for data persistence.
Spring Data jpa
Spring Data JPA frees us from the operation of the Dao layer, and basically all CRUD can be implemented on it. In the actual work project, it is recommended to use Spring Data JPA + ORM (such as: hibernate) to complete the operation, which provides great convenience when switching between different ORM frameworks. At the same time, it also makes the database layer operation more simple and convenient to decouple.
The relationship among Hibernate, JPA and Spring Data JPA
JPA is a set of specifications made up of interfaces and abstract classes internally. Hibernate is a mature ORM framework, and Hibernate implements the JPA specification, so we can also call hibernate an implementation of JPA. We use JPA's API programming, which means that we look at the problem from a higher point of view (interface-oriented programming) Spring Data JPA is a set of more advanced encapsulation of JPA operations provided by Spring, and it is a solution dedicated to data persistence under the JPA specification. The above is the explanation of the relationship among hibernate, JPA and Spring Data JPA.
Summary:
JPA is a specification, Hibernate implements the JPA specification, that is, Hibernate is an implementation of JPA, while Spring Data JPA is a more advanced encapsulation of JPA, making its dao coding easier.
CRUD operation
Crud operation of hibernate
First create a database table
Create hibernate core profile hibernate.cfg.xml
Org.hibernate.dialect.MySQLDialect com.mysql.jdbc.Driver jdbc:mysql:///hibernate root root org.hibernate.connection.C3P0ConnectionProvider true true update thread
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.