JPA learning-Section 2: Introduction to the JPA development environment and ideas

Source: Internet
Author: User

1. download relevant jar files

Http://hibernate.org/orm/ download hibernate, unzip

Http://www.slf4j.org/download.html download slf4j, unzip

Http://www.apache.org/dyn/closer.cgi/logging/log4j/2.0.2/apache-log4j-2.0.2-bin.zip download log4j, unzip

2. Develop the jar on which JPA depends

Hibernate-release-4.3.6.Final \ Lib \ required \ *. Jar

Hibernate-release-4.3.6.Final \ Lib \ JPA \ hibernate-entitymanager-4.3.6.Final.jar

Hibernate-release-4.3.6.Final \ Lib \ optional \ ehcache \ slf4j-api-1.6.1.jar

Iii. JPA configuration file

The JPA specification requires persistence. XML to be placed under the META-INF directory of the class path, the file name is fixed, and the configuration template is as follows:

<?xml version="1.0"?><persistence xmlns="http://java.sun.com/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence                 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"     version="1.0">  <persistence-unit name="itcast" transaction-type="RESOURCE_LOCAL">      <properties>         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>         <property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver"/>         <property name="hibernate.connection.username" value="root"/>         <property name="hibernate.connection.password" value="123456"/>         <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/itcast?useUnicode=true&amp;characterEncoding=UTF-8"/>         <property name="hibernate.hbm2ddl.auto" value="update"/>      </properties>  </persistence-unit></persistence>

Comparison:

1. Create a table and write the configuration file and Entity Bean Based on the table. This is a traditional database modeling solution.

2. First write the configuration file and entity-class bean, and then regenerate the table. This is the idea of Domain Modeling. This idea is more OOP than the previous one.

JPA learning-Section 2: Introduction to the JPA development environment and ideas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.