官术网_书友最值得收藏!

Chapter 3. EclipseLink JPA Persistence Provider

The Java Persistence API (JPA) is a component of EJB 3.0 and replaces CMP and JDO. Oracle's strategic Java persistence implementation within Oracle Fusion Middleware 11g is Oracle TopLink 11g, which is based on the open source EclipseLink. EclipseLink is based on an older version of TopLink, which Oracle contributed to Eclipse. The EclipseLink version in Oracle Fusion Middleware 11g supports the JPA 1.0 specification. In this chapter, we shall discuss the JPA framework and the EclipseLink JPA persistence provider.

What is a JPA persistence provider? A JPA persistence provider is an implementation of the JPA; JPA is just a specification. Various JPA persistence providers such as Hibernate, Apache OpenJPA, and JPA for WebSphere Application Server are available, but we shall be discussing the persistence provider in Oracle Fusion Middleware: the EclipseLink JPA persistence provider. This section is not meant to be a repetition of the JPA specification (http://jcp.org/en/jsr/detail?id=220), or the EclipseLink JPA documentation (http://wiki.eclipse.org/Category:JPA), but a primer and an introduction to some of the features/values used in this book. In this chapter, we shall discuss the following:

  • How to specify the EclipseLink persistence provider?
  • The JPA framework
    • The advantages of JPA
    • What is required for JPA?
  • Types of Entity Managers
    • Container-managed entity manager
    • Application-managed entity manager
  • EclipseLink JPA
    • Metadata annotations
    • XML mapping metadata
    • Entity identity
    • Entity relationships
  • EclispeLink JPA persistence unit properties

Specifying the EclipseLink persistence provider

The minimum required configuration to start using the EclipseLink persistence provider is to specify the persistence provider in the configuration file persistence.xml. The persistence provider is specified in the META-INF/persistence.xml configuration file in the provider sub-element of the persistence-unit element.

<?xml version="1.0" encoding="Cp1252" ?>
<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"
xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="em">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:/app/jdbc/jdbc/OracleDBConnectionDS</jta-data-source>
<class>model.Catalog</class>
<properties>
...
</properties>
</persistence-unit>
</persistence>

主站蜘蛛池模板: 镶黄旗| 灵璧县| 志丹县| 修武县| 兴化市| 水城县| 化德县| 原阳县| 万州区| 深泽县| 东安县| 子洲县| 宽甸| 磴口县| 托克托县| 松江区| 石首市| 尖扎县| 灌南县| 鹤峰县| 阆中市| 凭祥市| 天门市| 大丰市| 辽源市| 兴安盟| 大兴区| 区。| 广河县| 安岳县| 天镇县| 靖边县| 秭归县| 常熟市| 碌曲县| 阳山县| 宿迁市| 淳化县| 蒙阴县| 北宁市| 轮台县|