JPA Quick Start (a)
https://www.jianshu.com/p/8acf33afa41a
Author: Zhong Xin Ling, a senior lecturer knock Ding wolf education. Original articles, please indicate the source.
Introduction to JPA
JPA is referred to as the Java Persistence API, the Chinese name of the Java Persistence API, is JDK 5.0 annotations or XML description of the object - mapping between relational tables, solid objects and run persistence to the database.
Sun introduced the new JPA ORM specification for two reasons:
First, simplify the existing Java EE and Java SE application development work;
Second, Sun hopes the integration of ORM technology, the world normalized.
JPA's mission is to provide persistent POJO standards, we can see, after several years of practice and exploration, can run independently from the container, facilitate the development and testing of the concept has gained a. Hibernate3.2 +, TopLink 10.1.3 and have provided OpenJPA implementation of JPA.
JPA's overall thinking and existing Hibernate, TopLink, JDO and other ORM frameworks broadly consistent. In general, JPA includes the following three aspects of the technology:
ORM mapping metadata
XML annotation and JPA support JDK5.0 form two kinds of metadata, the metadata describes the mapping relationships between the objects and the table, the frame whereby the entity object persisted to the database tables;
API
For operating entity object, perform CRUD operations, the framework in the background alternative we have completed everything, developers freed from the tedious JDBC and SQL code.
Query Language
This is the persistence of a very important operation aspect, rather than object-oriented database query language for query data, to avoid the tight coupling process SQL statements.
JPA development environment to build
- dependent jar package
if maven item, add the following to the configuration file pom.xml
<build>
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <target>1.8</target> <source>1.8</source> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.6