|
|
(12 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | {{EclipseLink_UserGuide
| |
− | |info=y
| |
− | |toc=n
| |
− | |eclipselink=y
| |
− | |eclipselinktype=JPA}}
| |
− | =Specifying Object-Relational Mappings Using orm.xml=
| |
− | Use the <tt>orm.xml</tt> file to apply the metadata to the persistence unit. This metadata is a union of all the mapping files and the annotations (if there is no <tt>xml-mapping-metadata-complete</tt> element). If you use one mapping <tt>orm.xml</tt> file for your metadata and place this file in a <tt>META-INF</tt> directory on the classpath, then you do not need to explicitly list it. The EclipseLink persistence provider will automatically search for this file (<tt>orm.xml</tt>) and use it.
| |
| | | |
− | If you use a different name for your mapping files or place them in a different location, you must list them in the <code>mapping-file</code> element of the [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Configuration/JPA/persistence.xml|persistence.xml file]], as shown here:
| |
| | | |
− | <source lang="xml">
| |
− | <persistence-unit name="EmployeeService">
| |
− | <jta-data-source>jdbc/EmployeeServiceDS</jta-data-source>
| |
− | <mapping-file>META-INF/employee_service_queries.xml</mapping-file>
| |
− | </persistence-unit>
| |
− | </source>
| |
− | {{EclipseLink_Note
| |
− | |note=In this example, the <tt>orm.xml</tt> file is not listed -- the persistence provider finds it by default.
| |
− | }}
| |
| | | |
− | | + | '''[[Image:Elug_draft_icon.png|Warning]] See "About Object-Relational Mapping" in the [http://www.eclipse.org/eclipselink/documentation/ EclipseLink Concepts Guide]''' |
− | | + | |
− | ==Advantages and Disadvantages of Using XML==
| + | |
− | Some advantages of using XML instead of [[EclipseLink/UserGuide/JPA/Basic JPA Development/Configuration/JPA/Annotations|Annotations]] include:
| + | |
− | * No coupling between the metadata and the source code
| + | |
− | * Compliance with the existing, pre-EJB 3.0 development process
| + | |
− | * Support in IDEs and source control systems
| + | |
− | | + | |
− | The main disadvantages of mapping with XML include:
| + | |
− | * Its inherent complexitiy (when compared to annotations)
| + | |
− | * The need for replication of the code context
| + | |
− | | + | |
− | | + | |
− | {{EclipseLink_JPA
| + | |
− | |previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Configuration/JPA/Annotations|Annotations]]
| + | |
− | |next=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Configuration/JPA/Defaults|Defaults]]
| + | |
− | |up=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Configuration|Configuration]]
| + | |
− | |version=2.2.0 DRAFT}}
| + | |