Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Introduction to Mappings (ELUG)"

(Mapping Converters and Transformers)
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Image:Elug draft icon.png]] '''For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/ '''
 +
 +
----
 +
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
[[Special:Whatlinkshere/Introduction to Mappings (ELUG)|Related Topics]]</div>EclipseLink can transform data between an object representation and a representation specific to a data source. This transformation is called mapping and it is the core of a EclipseLink project.
+
[[Special:Whatlinkshere/Introduction to Mappings (ELUG)|Related Topics]]</div>EclipseLink can transform data between an object representation and a representation specific to a data source. This transformation is called mapping and it is the core of an EclipseLink project.
  
 
A mapping corresponds to a single data member of a domain object. It associates the object data member with its data source representation and defines the means of performing the two-way conversion between object and data source.
 
A mapping corresponds to a single data member of a domain object. It associates the object data member with its data source representation and defines the means of performing the two-way conversion between object and data source.
Line 7: Line 11:
  
 
==Mapping Types==
 
==Mapping Types==
 
 
This table describes the mapping types that EclipseLink supports.
 
This table describes the mapping types that EclipseLink supports.
  
  
 
<span id="Table 16-1"></span>
 
<span id="Table 16-1"></span>
''''' EclipseLink Mapping Types'''''
 
  
{| class="RuleFormalWideMax" dir="ltr" title="EclipseLink Mapping Types" summary="This table describes the mapping types that EclipseLink supports and indicates which are basic and advanced." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
+
{| class="RuleFormalWideMax" dir="ltr" title="EclipseLink Mapping Types" summary="This table describes the mapping types that EclipseLink supports." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
! id="r1c1-t2" align="left" valign="bottom" | '''Type'''
 
! id="r1c1-t2" align="left" valign="bottom" | '''Type'''
Line 22: Line 24:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
Relational (see [[#Relational Mappings]])
+
[[#Relational Mappings|Relational]]
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
Mappings that transform any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data model.
 
Mappings that transform any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data model.
Line 31: Line 33:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type (see [[#Object-Relational Data Type Mappings]])
+
[[#Object-Relational Data Type Mappings|Object-relational data type]]
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
Mappings that transform certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings let you map an object model into an object-relational data type data model.
 
Mappings that transform certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings let you map an object model into an object-relational data type data model.
Line 40: Line 42:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
EIS (see [[#EIS Mappings]])
+
[[#EIS Mappings|EIS]]
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
Mappings that transform object data members to the EIS record format defined by the object's descriptor.
 
Mappings that transform object data members to the EIS record format defined by the object's descriptor.
Line 49: Line 51:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
XML (see [[#XML Mappings]])
+
[[#XML Mappings|XML]]
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
Mappings that transform object data members to the XML elements of an XML document whose structure is defined by an XML schema document (XSD).
 
Mappings that transform object data members to the XML elements of an XML document whose structure is defined by an XML schema document (XSD).
Line 58: Line 60:
 
|}
 
|}
  
<br />
 
  
 
For more information, see the following:
 
For more information, see the following:
 
 
* [[Creating%20a%20Mapping%20(ELUG)#CBBHHHJC|Creating a Mapping]]
 
* [[Creating%20a%20Mapping%20(ELUG)#CBBHHHJC|Creating a Mapping]]
 
* [[Configuring%20a%20Mapping%20(ELUG)#CEGFEFJG|Configuring a Mapping]]
 
* [[Configuring%20a%20Mapping%20(ELUG)#CEGFEFJG|Configuring a Mapping]]
 +
 +
  
 
==Mapping Concepts==
 
==Mapping Concepts==
 
 
This section describes concepts unique to EclipseLink mappings, including the following:
 
This section describes concepts unique to EclipseLink mappings, including the following:
 
+
* [[#Mapping Architecture|Mapping Architecture]] (applicable to relational and nonrelational mappings)
* [[#Mapping Architecture]] (applicable to relational and nonrelational mappings)
+
* [[#Example Mapping|Example Mapping]] (applicable to relational and nonrelational mappings)
* [[#Example Mapping]] (applicable to relational and nonrelational mappings)
+
* [[#Automatic Mappings|Automatic Mappings]]
* [[#Automatic Mappings]]
+
** [[#JPA Automapping|JPA Automapping]] (applicable to relational mappings)
** [[#JPA Automapping]] (applicable to relational mappings)
+
** [[#Automapping with Workbench at Development Time|Automapping with Workbench at Development Time]] (applicable to relational and nonrelational mappings)
** [[#Automapping with Workbench at Development Time]] (applicable to relational and nonrelational mappings)
+
** [[#JAXB Project Generation at Development Time|JAXB Project Generation at Development Time]] (applicable to XML mappings)
** [[#JAXB Project Generation at Development Time]] (applicable to XML mappings)
+
* [[#Indirection (Lazy Loading)|Indirection (Lazy Loading)]] (applicable to relational mappings)
* [[#Indirection (Lazy Loading)]] (applicable to relational mappings)
+
** [[#Value Holder Indirection|Value Holder Indirection]]
** [[#Value Holder Indirection]]
+
** [[#Transparent Indirect Container Indirection|Transparent Indirect Container Indirection]]
** [[#Transparent Indirect Container Indirection]]
+
** [[#Proxy Indirection|Proxy Indirection]]
** [[#Proxy Indirection]]
+
** [[#Weaved IndirectionW|eaved Indirection]]
** [[#Weaved Indirection]]
+
** [[#Indirection and JPA|Indirection and JPA]]
** [[#Indirection and JPA]]
+
** [[#Indirection, Serialization, and Detachment|Indirection, Serialization, and Detachment]]
** [[#Indirection, Serialization, and Detachment]]
+
* [[#Method Accessors and Attribute Accessors|Method Accessors and Attribute Accessors]] (applicable to relational and nonrelational mappings)
* [[#Method Accessors and Attribute Accessors]] (applicable to relational and nonrelational mappings)
+
* [[#Mapping Converters and Transformers|Mapping Converters and Transformers]]
* [[#Mapping Converters and Transformers]]
+
** [[#Serialized Object Converter|Serialized Object Converter]] (applicable to relational and nonrelational mappings)
** [[#Serialized Object Converter]] (applicable to relational and nonrelational mappings)
+
** [[#Type Conversion Converter|Type Conversion Converter]] (applicable to relational and nonrelational mappings)
** [[#Type Conversion Converter]] (applicable to relational and nonrelational mappings)
+
** [[#Object Type Converter|Object Type Converter]] (applicable to XML mappings)
** [[#Object Type Converter]] (applicable to XML mappings)
+
** [[#Simple Type Translator|Simple Type Translator]] (applicable to XML mappings)
** [[#Simple Type Translator]] (applicable to XML mappings)
+
** [[#Transformation Mappings|Transformation Mappings]] (applicable to relational and nonrelational mappings)
** [[#Transformation Mappings]] (applicable to relational and nonrelational mappings)
+
* [[#Mappings and XPath|Mappings and XPath]] (applicable to XML mappings)
* [[#Mappings and XPath]] (applicable to XML mappings)
+
* [[#Mappings and xsd:list and xsd:union Types|Mappings and xsd:list and xsd:union Types]] (applicable to XML mappings)
* [[#Mappings and xsd:list and xsd:union Types]] (applicable to XML mappings)
+
* [[#Mappings and the jaxb:class Customization|Mappings and the jaxb:class Customization]] (applicable to XML mappings)
* [[#Mappings and the jaxb:class Customization]] (applicable to XML mappings)
+
* [[#Mappings and JAXB Typesafe Enumerations|Mappings and JAXB Typesafe Enumerations]] (applicable to XML mappings)
* [[#Mappings and JAXB Typesafe Enumerations]] (applicable to XML mappings)
+
 
+
  
  
 
===Mapping Architecture===
 
===Mapping Architecture===
 
 
To define a mapping, you draw upon the following components:
 
To define a mapping, you draw upon the following components:
 
 
* The data representation specific to the data source (such as a relational database table or schema-defined XML element) in which you store the object's data.
 
* The data representation specific to the data source (such as a relational database table or schema-defined XML element) in which you store the object's data.
 
* A descriptor for a particular object class.
 
* A descriptor for a particular object class.
 
* An object class to map.
 
* An object class to map.
  
<br />
 
  
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
Line 111: Line 107:
 
|}
 
|}
  
<br />
 
  
For an example of a typical EclipseLink mapping, see [[#Example Mapping]].
+
For an example of a typical EclipseLink mapping, see [[#Example Mapping|Example Mapping]].
  
The type of data source you define in your EclipseLink project determines the type of mappings you can use and how you configure them. In a persistent project, you use mappings to persist to a data source. In a nonpersistent project, you use mappings simply to transform between the object format and some other data representation (such as XML). For more information about data source and project types, see [[Introduction%20to%20Projects#BABEHBCI|EclipseLink Project Types]].
+
The type of data source you define in your EclipseLink project determines the type of mappings you can use and how you configure them. In a persistent project, you use mappings to persist to a data source. In a nonpersistent project, you use mappings simply to transform between the object format and some other data representation (such as XML). For more information about data source and project types, see [[Introduction%20to%20Projects (ELUG)|EclipseLink Project Types]].
  
 
A descriptor represents a particular domain object: it describes the object's class. It owns mappings: one mapping for each of the class data members that you intend to persist or transform in memory.
 
A descriptor represents a particular domain object: it describes the object's class. It owns mappings: one mapping for each of the class data members that you intend to persist or transform in memory.
  
<br />
 
  
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
Line 126: Line 120:
 
|}
 
|}
  
<br />
 
  
 
For more information about descriptors, see [[Introduction%20to%20Descriptors%20(ELUG)#CHECEAAE|Introduction to Descriptors]].
 
For more information about descriptors, see [[Introduction%20to%20Descriptors%20(ELUG)#CHECEAAE|Introduction to Descriptors]].
  
EclipseLink provides mappings to handle a wide variety of data types and data representations. For more information, see [[#Mapping Types]].
+
EclipseLink provides mappings to handle a wide variety of data types and data representations. For more information, see [[#Mapping Types|Mapping Types]].
 +
 
 +
All mappings are subclasses of the <tt>org.eclipse.persistence.mappings.DatabaseMapping</tt> class. For more information about the mapping API, see [[#Mapping API|Mapping API]].
  
All mappings are subclasses of the <tt>org.eclipse.persistence.mappings.DatabaseMapping</tt> class. For more information about the mapping API, see [[#Mapping API]].
 
  
 
===Example Mapping===
 
===Example Mapping===
Line 138: Line 132:
 
Although EclipseLink supports more complex mappings, most EclipseLink classes map to a single database table or XML element that defines the type of information available in the class. Each object instance of a given class maps to a single row comprising the object's attributes, plus an identifier (the primary key) that uniquely identifies the object.
 
Although EclipseLink supports more complex mappings, most EclipseLink classes map to a single database table or XML element that defines the type of information available in the class. Each object instance of a given class maps to a single row comprising the object's attributes, plus an identifier (the primary key) that uniquely identifies the object.
  
[[#Figure 16-1|How Classes and Objects Map to a Database Table]] illustrates the simplest database mapping case in which:
+
The [[#Figure 16-1|How Classes and Objects Map to a Database Table]] figure illustrates the simplest database mapping case in which:
 
* '''Table_X''' in the database represents '''Class_X'''.
 
* '''Table_X''' in the database represents '''Class_X'''.
 
* '''Object_X1''' and '''Object_X2''' are instances of '''Class_X'''.
 
* '''Object_X1''' and '''Object_X2''' are instances of '''Class_X'''.
Line 149: Line 143:
 
[[Image:example_map1.gif|How Classes and Objects Map to a Database Table]]<br /><br />
 
[[Image:example_map1.gif|How Classes and Objects Map to a Database Table]]<br /><br />
  
EclipseLink provides you with the tools to build these mappings, from the simple mappings illustrated in [[#Figure 16-1|How Classes and Objects Map to a Database Tabl]], to complex mappings.
+
EclipseLink provides you with the tools to build these mappings, from the simple mappings illustrated in the [[#Figure 16-1|How Classes and Objects Map to a Database Tabl]] figure, to complex mappings.
  
For an additional example of a relational mapping, see [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Figure 31-1|Direct-to-Field Mapping]].
+
For an additional example of a relational mapping, see the [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Figure 31-1|Direct-to-Field Mapping]] figure.
 +
 
 +
For an example of a nonrelational mapping, see the [[Introduction%20to%20XML%20Mappings%20(ELUG)#Figure 58-34|XML Transformation Mappings]] figure.
  
For an example of a nonrelational mapping, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Figure 58-34|XML Transformation Mappings]].
 
  
 
===Automatic Mappings===
 
===Automatic Mappings===
 
+
Typically, you use the Workbench to define mappings on a class-by-class and data member-by-data-member basis manually (see [[Creating%20a%20Mapping%20(ELUG)#Creating Mappings Manually During Development|Creating Mappings Manually During Development]]).
Typically, you use the Workbench to define mappings on a class-by-class and data member-by-data-member basis manually (see [[Creating%20a%20Mapping%20(ELUG)#CBBFCFCF|Creating Mappings Manually During Development]]).
+
  
 
Alternatively, you can take advantage of the following:
 
Alternatively, you can take advantage of the following:
 
+
* [[#JPA Automapping|JPA Automapping]]
* [[#JPA Automapping]]
+
* [[#Automapping with Workbench at Development Time|Automapping with Workbench at Development Time]]
* [[#Automapping with Workbench at Development Time]]
+
* [[#JAXB Project Generation at Development Time|JAXB Project Generation at Development Time]]
* [[#JAXB Project Generation at Development Time]]
+
 
+
  
  
 
====JPA Automapping====
 
====JPA Automapping====
 
+
To configure automapping in a JPA project, you just need to annotate your persistence classes with <tt>@Entity</tt> and define their primary key with <tt>@Id</tt> (or define the list of entities and their primary key fields in your <tt>orm.xml</tt>) and the EclipseLink JPA persistence provider will automatically map all unmapped properties. You can also configure <tt>persistence.xml</tt> properties to automatically create or replace the corresponding database tables. For more information, see [[Introduction to EclipseLink JPA (ELUG)|EclipseLink JPA Overview]].
To configure automapping in a JPA project, you just need to annotate your persistence classes with <tt>@Entity</tt> and define their primary key with <tt>@Id</tt> (or define the list of entities and their primary key fields in your <tt>orm.xml</tt>) and the EclipseLink JPA persistence provider will automatically map all unmapped properties. You can also configure <tt>persistence.xml</tt> properties to automatically create or replace the corresponding database tables. For more information, see [[EclipseLink JPA Overview (ELUG)].
+
 
+
  
  
 
====Automapping with Workbench at Development Time====
 
====Automapping with Workbench at Development Time====
 
+
You can use Workbench '''Automap''' feature to automatically define default mappings for every class and data member in your project (see [[Creating%20a%20Mapping%20(ELUG)#Creating Mappings Automatically During Development|Creating Mappings Automatically During Development]]).
You can use Workbench '''Automap''' feature to automatically define default mappings for every class and data member in your project (see [[Creating%20a%20Mapping%20(ELUG)#BABCIGCD|Creating Mappings Automatically During Development]]).
+
  
 
Workbench automapping is available for all project types and assumes that both the object model and database schema are already defined.
 
Workbench automapping is available for all project types and assumes that both the object model and database schema are already defined.
 +
  
 
====JAXB Project Generation at Development Time====
 
====JAXB Project Generation at Development Time====
 
 
JAXB provides an API and a tool that allow automatic two-way mapping between XML documents and Java objects. The JAXB compiler generates all the Java classes and mappings based on the provided Document Type Definition (DTD) and a schema definition.
 
JAXB provides an API and a tool that allow automatic two-way mapping between XML documents and Java objects. The JAXB compiler generates all the Java classes and mappings based on the provided Document Type Definition (DTD) and a schema definition.
  
 
For more information on JAXB, see ''Architecture for XML Binding (JAXB): A Primer'' at <tt>http://java.sun.com/developer/technicalArticles/xml/jaxb/indexl</tt>
 
For more information on JAXB, see ''Architecture for XML Binding (JAXB): A Primer'' at <tt>http://java.sun.com/developer/technicalArticles/xml/jaxb/indexl</tt>
  
For more information on XML mappings, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#CHEGCIBF|Introduction to XML Mappings]].
+
For more information on XML mappings, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Introduction to XML Mappings|Introduction to XML Mappings]].
 +
 
  
 
===Indirection (Lazy Loading)===
 
===Indirection (Lazy Loading)===
 
 
By default, when EclipseLink retrieves a persistent object, it retrieves all of the dependent objects to which it refers. When you configure indirection (also known as lazy reading, lazy loading, and just-in-time reading) for an attribute mapped with a relationship mapping, EclipseLink uses an indirection object as a place holder for the referenced object: EclipseLink defers reading the dependent object until you access that specific attribute. This can result in a significant performance improvement, especially if the application is interested only in the contents of the retrieved object, rather than the objects to which it is related.
 
By default, when EclipseLink retrieves a persistent object, it retrieves all of the dependent objects to which it refers. When you configure indirection (also known as lazy reading, lazy loading, and just-in-time reading) for an attribute mapped with a relationship mapping, EclipseLink uses an indirection object as a place holder for the referenced object: EclipseLink defers reading the dependent object until you access that specific attribute. This can result in a significant performance improvement, especially if the application is interested only in the contents of the retrieved object, rather than the objects to which it is related.
  
 
We strongly recommend using indirection for all relationship mappings. Not only does this lets you optimize data source access, but it also allows EclipseLink to optimize the unit of work processing, cache access, and concurrency.
 
We strongly recommend using indirection for all relationship mappings. Not only does this lets you optimize data source access, but it also allows EclipseLink to optimize the unit of work processing, cache access, and concurrency.
  
<br />
 
  
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
| align="left" |
 
| align="left" |
'''Note:''' The use of indirection is especially important for providing a proper maintenance of bidirectional relationships (see ). In this case, you must use indirection. If you are operating with collections, you must use transparent indirection (see [[#Transparent Indirect Container Indirection]]).
+
'''Note:''' The use of indirection is especially important for providing a proper maintenance of bidirectional relationships. In this case, you must use indirection. If you are operating with collections, you must use transparent indirection (see [[#Transparent Indirect Container Indirection|Transparent Indirect Container Indirection]]).
 
|}
 
|}
  
<br />
 
  
[[#Figure 16-2|EclipseLink Indirection]] shows an indirection example. Without indirection, reading the <tt>Order</tt> object also reads the dependent collection of <tt>LineItem</tt> objects. With indirection, reading the <tt>Order</tt> object does not read the dependent collection of <tt>LineItem</tt> objects: the <tt>lineItems</tt> attribute refers to an indirection object. You can access other attributes (such as <tt>customerId</tt>), but EclipseLink reads the dependent <tt>LineItem</tt> objects only if and when you access the <tt>lineItems</tt> attribute.
+
The [[#Figure 16-2|EclipseLink Indirection]] figure shows an indirection example. Without indirection, reading the <tt>Order</tt> object also reads the dependent collection of <tt>LineItem</tt> objects. With indirection, reading the <tt>Order</tt> object does not read the dependent collection of <tt>LineItem</tt> objects: the <tt>lineItems</tt> attribute refers to an indirection object. You can access other attributes (such as <tt>customerId</tt>), but EclipseLink reads the dependent <tt>LineItem</tt> objects only if and when you access the <tt>lineItems</tt> attribute.
  
  
Line 211: Line 198:
  
 
EclipseLink supports the following types of indirection:
 
EclipseLink supports the following types of indirection:
 
 
* [[#Value Holder Indirection|Value Holder Indirection]]
 
* [[#Value Holder Indirection|Value Holder Indirection]]
 
* [[#Transparent Indirect Container Indirection|Transparent Indirect Container Indirection]]
 
* [[#Transparent Indirect Container Indirection|Transparent Indirect Container Indirection]]
Line 218: Line 204:
 
When using indirection with an object that your application serializes, you must consider the effect of any untriggered indirection objects at deserialization time (see [[#Indirection, Serialization, and Detachment|Indirection, Serialization, and Detachment]]).
 
When using indirection with an object that your application serializes, you must consider the effect of any untriggered indirection objects at deserialization time (see [[#Indirection, Serialization, and Detachment|Indirection, Serialization, and Detachment]]).
  
For information on configuring indirection, see [[Configuring%20a%20Mapping%20(ELUG)#CEGDDEEA|Configuring Indirection (Lazy Loading)]].
+
For information on configuring indirection, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring Indirection (Lazy Loading)|Configuring Indirection (Lazy Loading)]].
 
+
  
  
 
====Value Holder Indirection====
 
====Value Holder Indirection====
 
 
Persistent classes that use indirection must replace relationship attributes with value holder attributes. A value holder is an instance of a class that implements the <tt>ValueHolderInterface</tt> interface, such as <tt>ValueHolder</tt>. This object stores the information necessary to retrieve the object it is replacing from the database. If the application does not access the value holder, the replaced object is never read from the database.
 
Persistent classes that use indirection must replace relationship attributes with value holder attributes. A value holder is an instance of a class that implements the <tt>ValueHolderInterface</tt> interface, such as <tt>ValueHolder</tt>. This object stores the information necessary to retrieve the object it is replacing from the database. If the application does not access the value holder, the replaced object is never read from the database.
  
 
To obtain the object that the value holder replaces, use the <tt>getValue</tt> and <tt>setValue</tt> methods of the <tt>ValueHolderInterface</tt>. A convenient way of using these methods is to hide the <tt>getValue</tt> and <tt>setValue</tt> methods of the <tt>ValueHolderInterface</tt> inside <tt>get</tt> and <tt>set</tt> methods, as shown in the following illustrations.
 
To obtain the object that the value holder replaces, use the <tt>getValue</tt> and <tt>setValue</tt> methods of the <tt>ValueHolderInterface</tt>. A convenient way of using these methods is to hide the <tt>getValue</tt> and <tt>setValue</tt> methods of the <tt>ValueHolderInterface</tt> inside <tt>get</tt> and <tt>set</tt> methods, as shown in the following illustrations.
  
[[#Figure 16-3|Address Object Not Read]] shows the <tt>Employee</tt> object being read from the database. The <tt>Address</tt> object is not read and will not be created unless it is accessed.
+
The [[#Figure 16-3|Address Object Not Read]] figure shows the <tt>Employee</tt> object being read from the database. The <tt>Address</tt> object is not read and will not be created unless it is accessed.
  
  
Line 236: Line 220:
 
[[Image:vhstep1.gif|Address Object Not Read]]<br /><br />
 
[[Image:vhstep1.gif|Address Object Not Read]]<br /><br />
  
The first time the address is accessed, as in [[#Figure 16-4|Initial Request]], the <tt>ValueHolder</tt> reads and returns the <tt>Address</tt> object.
+
The first time the address is accessed, as in the [[#Figure 16-4|Initial Request]] figure, the <tt>ValueHolder</tt> reads and returns the <tt>Address</tt> object.
  
  
Line 245: Line 229:
  
  
Subsequent requests for the address do not access the database, as shown in [[#Figure 16-5|Subsequent Requests]].
+
Subsequent requests for the address do not access the database, as shown in the [[#Figure 16-5|Subsequent Requests]] figure.
  
  
Line 253: Line 237:
 
[[Image:vhstep3.gif|Subsequent Requests]]<br /><br />
 
[[Image:vhstep3.gif|Subsequent Requests]]<br /><br />
  
If you are using method access ( [[Configuring%20a%20Mapping%20(ELUG)#CEGCFIGE|Configuring Method or Direct Field Accessing at the Mapping Level]]), the get and set methods specified in the mapping must access the instance of <tt>ValueHolderInterface</tt>, rather than the object referenced by the value holder. The application should not use these getter and setter, but use the getter and setter that hide the usage of value holders. For more information, see [[Configuring%20a%20Mapping%20(ELUG)#CEGFHCJF|Configuring ValueHolder Indirection With Method Accessing]].
+
If you are using method access ( [[Configuring%20a%20Mapping%20(ELUG)#Configuring Method or Direct Field Accessing at the Mapping Level|Configuring Method or Direct Field Accessing at the Mapping Level]]), the get and set methods specified in the mapping must access the instance of <tt>ValueHolderInterface</tt>, rather than the object referenced by the value holder. The application should not use these getter and setter, but use the getter and setter that hide the usage of value holders. For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring ValueHolder Indirection With Method Accessing|Configuring ValueHolder Indirection With Method Accessing]].
  
 
For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).
 
For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).
 +
  
 
====Transparent Indirect Container Indirection====
 
====Transparent Indirect Container Indirection====
 
+
Transparent indirect container (see [[Configuring%20a%20Mapping%20(ELUG)#Configuring Container Policy|Configuring Container Policy]]) indirection lets you declare any relationship attribute of a persistent class that holds a collection of related objects as any of the following:
Transparent indirect container (see [[Configuring%20a%20Mapping%20(ELUG)#CHDFGJAI|Configuring Container Policy]]) indirection lets you declare any relationship attribute of a persistent class that holds a collection of related objects as any of the following:
+
 
+
 
* <tt>java.util.Collection</tt>
 
* <tt>java.util.Collection</tt>
 
* <tt>java.util.Hastable</tt>
 
* <tt>java.util.Hastable</tt>
Line 276: Line 259:
 
You can configure EclipseLink to automatically weave transparent indirect container indirection for JPA entities and Plain Old Java Object (POJO) classes. For more information, see the following:
 
You can configure EclipseLink to automatically weave transparent indirect container indirection for JPA entities and Plain Old Java Object (POJO) classes. For more information, see the following:
  
* [[EclipseLink%20Application%20Development%20(ELUG)#CCHJEDFH|Using Weaving]]
+
* [[Introduction to EclipseLink%20Application%20Development%20(ELUG)#Using Weaving|Using Weaving]]
* [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#BABCFFAB|Using EclipseLink JPA Weaving]]
+
* [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#Using EclipseLink JPA Weaving|Using EclipseLink JPA Weaving]]
 
+
  
  
 
====Proxy Indirection====
 
====Proxy Indirection====
 
+
Introduced in JDK 1.3, the Java class <tt>Proxy</tt> lets you use dynamic proxy objects as place-holders for a defined interface. Certain EclipseLink mappings (see the [[Configuring%20a%20Mapping%20(ELUG)#Table 117-4|Mapping Support for Indirection]] table) can be configured to use proxy indirection, which gives you the benefits of EclipseLink indirection without the need to include EclipseLink classes in your domain model. Proxy indirection is to one-to-one relationship mappings as indirect containers are to collection mappings.
Introduced in JDK 1.3, the Java class <tt>Proxy</tt> lets you use dynamic proxy objects as place-holders for a defined interface. Certain EclipseLink mappings (see [[Configuring%20a%20Mapping%20(ELUG)#CEGHCDFF|Table 117-4, "Mapping Support for Indirection"]]) can be configured to use proxy indirection, which gives you the benefits of EclipseLink indirection without the need to include EclipseLink classes in your domain model. Proxy indirection is to one-to-one relationship mappings as indirect containers are to collection mappings.
+
  
 
To use proxy indirection, your domain model must satisfy all of the following criteria:
 
To use proxy indirection, your domain model must satisfy all of the following criteria:
Line 289: Line 270:
 
* The target class of the one-to-one relationship must implement a public interface.
 
* The target class of the one-to-one relationship must implement a public interface.
 
* The one-to-one attribute on the source class must be of the <tt>interface</tt> type.
 
* The one-to-one attribute on the source class must be of the <tt>interface</tt> type.
* If you employ method accessing ( [[Configuring%20a%20Mapping%20(ELUG)#CEGCFIGE|Configuring Method or Direct Field Accessing at the Mapping Level]]), then the getter and setter methods must use the interface.
+
* If you employ method accessing ( [[Configuring%20a%20Mapping%20(ELUG)#Configuring Method or Direct Field Accessing at the Mapping Level|Configuring Method or Direct Field Accessing at the Mapping Level]]), then the getter and setter methods must use the interface.
  
Before using proxy indirection, be aware of the restrictions it places on how you use the unit of work (see [[#Proxy Indirection Restrictions]]).
+
Before using proxy indirection, be aware of the restrictions it places on how you use the unit of work (see [[#Proxy Indirection Restrictions|Proxy Indirection Restrictions|]]).
 
+
To configure proxy indirection, you can use the Workbench (see [[Configuring%20a%20Mapping%20(ELUG)#CEGFIGAA|How to Configure Indirection Using Workbench]]) or Java in an amendment method (see [[Configuring%20a%20Mapping%20(ELUG)#CEGCFCIE|Configuring Proxy Indirection]]).
+
  
 +
To configure proxy indirection, you can use the Workbench (see [[Configuring%20a%20Mapping%20(ELUG)#How to Configure Indirection Using Workbench|How to Configure Indirection Using Workbench]]) or Java in an amendment method (see [[Configuring%20a%20Mapping%20(ELUG)#Configuring Proxy Indirection|Configuring Proxy Indirection]]).
  
  
 
=====Proxy Indirection Restrictions=====
 
=====Proxy Indirection Restrictions=====
 
 
Proxy objects in Java are only able to intercept messages sent. If a primitive operation such as <tt><nowiki>==</nowiki></tt>, <tt>instanceof</tt>, or <tt>getClass</tt> is used on a proxy, it will not be intercepted. This limitation can require the application to be somewhat aware of the usage of proxy objects.
 
Proxy objects in Java are only able to intercept messages sent. If a primitive operation such as <tt><nowiki>==</nowiki></tt>, <tt>instanceof</tt>, or <tt>getClass</tt> is used on a proxy, it will not be intercepted. This limitation can require the application to be somewhat aware of the usage of proxy objects.
  
Line 315: Line 294:
  
 
For more information about clones and the unit of work, see [[Introduction%20to%20EclipseLink%20Transactions (ELUG)#CIHEGFDA|Introduction to EclipseLink Transactions]].
 
For more information about clones and the unit of work, see [[Introduction%20to%20EclipseLink%20Transactions (ELUG)#CIHEGFDA|Introduction to EclipseLink Transactions]].
 
  
  
 
====Weaved Indirection====
 
====Weaved Indirection====
 
 
For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).
 
For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).
  
For more information, see [[EclipseLink%20Application%20Development%20(ELUG)#CCHJEDFH|Using Weaving]].
+
For more information, see [[Introduction to EclipseLink%20Application%20Development%20(ELUG)#Using Weaving|Using Weaving]].
 
+
  
  
 
====Indirection and JPA====
 
====Indirection and JPA====
 
 
When you set mapping annotation attribute <tt>fetch</tt> to <tt>lazy</tt>, the EclipseLink JPA persistence provider uses indirection.
 
When you set mapping annotation attribute <tt>fetch</tt> to <tt>lazy</tt>, the EclipseLink JPA persistence provider uses indirection.
  
Line 336: Line 311:
 
For more information, see the following:
 
For more information, see the following:
  
* [[#Weaved Indirection]]
+
* [[#Weaved Indirection|Weaved Indirection]]
* [[EclipseLink%20Application%20Development%20(ELUG)#CCHJEDFH|Using Weaving]]
+
* [[Introduction to EclipseLink%20Application%20Development%20(ELUG)#Using Weaving|Using Weaving]]
 
+
  
  
 
====Indirection, Serialization, and Detachment====
 
====Indirection, Serialization, and Detachment====
 
 
When using indirection (lazy loading), it is likely that a graph of persistent objects will contain untriggered indirection objects. Because indirection objects are transient and do not survive serialization between one JVM and another, untriggered indirection objects will trigger an error if the relationship is accessed after deserialization.
 
When using indirection (lazy loading), it is likely that a graph of persistent objects will contain untriggered indirection objects. Because indirection objects are transient and do not survive serialization between one JVM and another, untriggered indirection objects will trigger an error if the relationship is accessed after deserialization.
  
 
The application must ensure that any indirect relationships that will be required after deserialization have been instantiated before serialization. This can be done through accessing the get method for any relationship using <tt>ValueHolder</tt> or weaved indirection, and by sending the <tt>size()</tt> method to any relationship using transparent indirection. If the application desired the relationships to be always instantiated on serialization, the serialization <tt>writeObject()</tt> method could be overwritten in the persistent class to first instantiate the desired relationships. Caution should be used for objects with many or deep relationships to avoid serializing large object graphs: ideally, only the relationships required by the client should be instantiated.
 
The application must ensure that any indirect relationships that will be required after deserialization have been instantiated before serialization. This can be done through accessing the get method for any relationship using <tt>ValueHolder</tt> or weaved indirection, and by sending the <tt>size()</tt> method to any relationship using transparent indirection. If the application desired the relationships to be always instantiated on serialization, the serialization <tt>writeObject()</tt> method could be overwritten in the persistent class to first instantiate the desired relationships. Caution should be used for objects with many or deep relationships to avoid serializing large object graphs: ideally, only the relationships required by the client should be instantiated.
  
When serializing JPA entities, any lazy relationships that have not been instantiated prior to serialization will trigger errors if they are accessed. If weaving is used on the server, and the entities are serialized to a client, the same weaved classes must exist on the client, either through static weaving of the jar, or through launching the client JVM using the EclipseLink agent.
+
When serializing JPA entities, any lazy relationships that have not been instantiated prior to serialization will trigger errors if they are accessed. If weaving is used on the server, and the entities are serialized to a client, the same weaved classes must exist on the client, either through static weaving of the jar, or through launching the client JVM using EclipseLink.
  
 
For more information, see the following:
 
For more information, see the following:
 
+
* [[Introduction to EclipseLink%20Application%20Development%20(ELUG)#Using Weaving|Using Weaving]]
* [[EclipseLink%20Application%20Development%20(ELUG)#CCHJEDFH|Using Weaving]]
+
* [[Using%20Advanced%20Unit%20of%20Work%20API%20(ELUG)#Merging Changes in Working Copy Clones|Merging Changes in Working Copy Clones]]
* [[Using%20Advanced%20Unit%20of%20Work%20API%20(ELUG)#CACCCFBD|Merging Changes in Working Copy Clones]]
+
  
 
===Method Accessors and Attribute Accessors===
 
===Method Accessors and Attribute Accessors===
 +
By default, EclipseLink uses direct access to access public attributes. Using EclipseLink, you can configure field access at the project level (see [[Configuring%20a%20Project%20(ELUG)#Configuring Method or Direct Field Access at the Project Level|Configuring Method or Direct Field Access at the Project Level]]) and at the mapping level ([[Configuring%20a%20Mapping%20(ELUG)#Configuring Method or Direct Field Accessing at the Mapping Level|Configuring Method or Direct Field Accessing at the Mapping Level]]).
  
By default, EclipseLink uses direct access to access public attributes. Using EclipseLink, you can configure field access at the project level (see [[Configuring%20a%20Project%20(ELUG)#BABCJDBH|Configuring Method or Direct Field Access at the Project Level]]) and at the mapping level ([[Configuring%20a%20Mapping%20(ELUG)#CEGCFIGE|Configuring Method or Direct Field Accessing at the Mapping Level]]).
 
  
 
===Mapping Converters and Transformers===
 
===Mapping Converters and Transformers===
 
 
If existing EclipseLink mappings do not meet your needs, you can create custom mappings using mapping extensions. These extensions include the following:
 
If existing EclipseLink mappings do not meet your needs, you can create custom mappings using mapping extensions. These extensions include the following:
 
 
* [[#Serialized Object Converter|Serialized Object Converter]]
 
* [[#Serialized Object Converter|Serialized Object Converter]]
 
* [[#Type Conversion Converter|Type Conversion Converter]]
 
* [[#Type Conversion Converter|Type Conversion Converter]]
Line 374: Line 344:
 
'''Note:''' You can use the mapping converters and transformers regardless of whether your data source is relational or nonrelational.
 
'''Note:''' You can use the mapping converters and transformers regardless of whether your data source is relational or nonrelational.
 
|}
 
|}
 
<br />
 
 
  
  
 
====Serialized Object Converter====
 
====Serialized Object Converter====
 
 
The serialized object converter is an extension of direct and direct collection mappings that lets you map complex objects into binary fields through Java object serialization. Serialized objects are normally stored in <tt>RAW</tt> or Binary Large Object (<tt>BLOB)</tt> fields in the database, or <tt>HEX</tt> or <tt>BASE64</tt> elements in an XML document.
 
The serialized object converter is an extension of direct and direct collection mappings that lets you map complex objects into binary fields through Java object serialization. Serialized objects are normally stored in <tt>RAW</tt> or Binary Large Object (<tt>BLOB)</tt> fields in the database, or <tt>HEX</tt> or <tt>BASE64</tt> elements in an XML document.
  
[[#Figure 16-6|Serialized Object Converter]] shows an example of a direct-to-field mappings that uses a serialized object converter. The attribute <tt>jobDescription</tt> contains a formatted text document that is stored in the JOB_DESC field of the database.
+
The [[#Figure 16-6|Serialized Object Converter]] figure shows an example of a direct-to-field mappings that uses a serialized object converter. The attribute <tt>jobDescription</tt> contains a formatted text document that is stored in the JOB_DESC field of the database.
  
 
<span id="Figure 16-6"></span>
 
<span id="Figure 16-6"></span>
Line 392: Line 358:
  
  
[[#Figure 16-7|Serialized Object Converter (nonrelational)]] demonstrates an example of a nonrelational mapping that uses a serialized object converter. The attribute <tt>jobDescription</tt> contains a formatted text document that EclipseLink stores in the <tt>JOB DESCRIPTION</tt> element of an XML schema.
+
The [[#Figure 16-7|Serialized Object Converter (nonrelational)]] figure demonstrates an example of a nonrelational mapping that uses a serialized object converter. The attribute <tt>jobDescription</tt> contains a formatted text document that EclipseLink stores in the <tt>JOB DESCRIPTION</tt> element of an XML schema.
  
 
<span id="Figure 16-7"></span>
 
<span id="Figure 16-7"></span>
Line 401: Line 367:
 
The serialized object converter relies on the Java serializer. Before you map a domain object with the serialized object converter, ensure that the domain object implements the <tt>java.io.Serializable</tt> interface (or inherits that implementation) and marks all nonserializable fields transient.
 
The serialized object converter relies on the Java serializer. Before you map a domain object with the serialized object converter, ensure that the domain object implements the <tt>java.io.Serializable</tt> interface (or inherits that implementation) and marks all nonserializable fields transient.
  
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#CEGJGBGD|Configuring a Serialized Object Converter]].
+
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Serialized Object Converter|Configuring a Serialized Object Converter]].
 
+
  
  
 
====Type Conversion Converter====
 
====Type Conversion Converter====
 
 
The type conversion converter is an extension of direct and direct collection mappings that lets you explicitly map a data source type to a Java type. For example, a <tt>Number</tt> in the data source can be mapped to a <tt>String</tt> in Java, or a <tt>java.util.Date</tt> in Java can be mapped to a <tt>java.sql.Date</tt> in the data source.
 
The type conversion converter is an extension of direct and direct collection mappings that lets you explicitly map a data source type to a Java type. For example, a <tt>Number</tt> in the data source can be mapped to a <tt>String</tt> in Java, or a <tt>java.util.Date</tt> in Java can be mapped to a <tt>java.sql.Date</tt> in the data source.
  
[[#Figure 16-8|Type Conversion Mapping (relational)]] illustrates a type conversion mapping (relational). Because the <tt>java.util.Date</tt> class is stored by default as a <tt>Timestamp</tt> in the database, it must first be converted to an explicit database type such as <tt>java.sql.Date</tt> (required only for DB2–most other databases have a single date data type that can store any date or time).
+
The [[#Figure 16-8|Type Conversion Mapping (relational)]] figure illustrates a type conversion mapping (relational). Because the <tt>java.util.Date</tt> class is stored by default as a <tt>Timestamp</tt> in the database, it must first be converted to an explicit database type such as <tt>java.sql.Date</tt> (required only for DB2–most other databases have a single date data type that can store any date or time).
  
 
<span id="Figure 16-8"></span>
 
<span id="Figure 16-8"></span>
Line 418: Line 382:
  
  
[[#Figure 16-9|Type Conversion Mapping (nonrelational)]] illustrates a type conversion mapping (nonrelational). <tt>java.util.Date</tt> object is mapped to a String in a XML schema.
+
The [[#Figure 16-9|Type Conversion Mapping (nonrelational)]] figure illustrates a type conversion mapping (nonrelational). <tt>java.util.Date</tt> object is mapped to a String in a XML schema.
  
 
<span id="Figure 16-9"></span>
 
<span id="Figure 16-9"></span>
Line 437: Line 401:
 
* <tt>YY-MM-DD HH:MM:SS</tt>
 
* <tt>YY-MM-DD HH:MM:SS</tt>
  
For more complex <tt>String</tt> to <tt>TIMESTAMP</tt> type conversion, consider a transformation mapping (see [[#Transformation Mappings]).
+
For more complex <tt>String</tt> to <tt>TIMESTAMP</tt> type conversion, consider a transformation mapping (see [[#Transformation Mappings|Transformation Mappings]]).
  
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#CEGBHCIC|Configuring a Type Conversion Converter]].
+
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Type Conversion Converter|Configuring a Type Conversion Converter]].
  
====Object Type Converter====
 
  
 +
====Object Type Converter====
 
The object type converter is an extension of direct and direct collection mappings that lets you match a fixed number of XML values to Java objects. Use this converter when the values in the schema differ from those in Java.
 
The object type converter is an extension of direct and direct collection mappings that lets you match a fixed number of XML values to Java objects. Use this converter when the values in the schema differ from those in Java.
  
[[#Figure 16-10|Object Type XML Converter]] illustrates an object type conversion between the <tt>Employee</tt> attribute <tt>gender</tt> and the XML element <tt>gender</tt>. If the value of the Java object attribute is <tt>Female</tt>, EclipseLink stores it in the XML element as <tt>F</tt>.
+
The [[#Figure 16-10|Object Type XML Converter]] figure illustrates an object type conversion between the <tt>Employee</tt> attribute <tt>gender</tt> and the XML element <tt>gender</tt>. If the value of the Java object attribute is <tt>Female</tt>, EclipseLink stores it in the XML element as <tt>F</tt>.
  
 
<span id="Figure 16-10"></span>
 
<span id="Figure 16-10"></span>
Line 453: Line 417:
  
  
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#CEGFEAHH|Configuring an Object Type Converter]].
+
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring an Object Type Converter|Configuring an Object Type Converter]].
 
+
  
  
 
====Simple Type Translator====
 
====Simple Type Translator====
 
 
The simple type translator is an extension of direct and direct collection mappings that lets you automatically translate an XML element value to an appropriate Java type based on the element's <tt><type></tt> attribute as defined in your XML schema.
 
The simple type translator is an extension of direct and direct collection mappings that lets you automatically translate an XML element value to an appropriate Java type based on the element's <tt><type></tt> attribute as defined in your XML schema.
  
Line 465: Line 427:
 
Using a simple type translator, you can make the XML document preserve type information. This is useful when your object model specifies generic object attributes such as <tt>java.lang.Object</tt> and <tt>java.io.Serializable</tt>, since they do not trigger specific type conversions in EclipseLink as do specific object attributes such as <tt>java.lang.Integer</tt> or <tt>java.util.Calendar</tt>.
 
Using a simple type translator, you can make the XML document preserve type information. This is useful when your object model specifies generic object attributes such as <tt>java.lang.Object</tt> and <tt>java.io.Serializable</tt>, since they do not trigger specific type conversions in EclipseLink as do specific object attributes such as <tt>java.lang.Integer</tt> or <tt>java.util.Calendar</tt>.
  
[[#Figure 16-11|Simple Type Translator]] illustrates a type translation XML mapping for the <tt>number</tt> attribute of the <tt>PhoneNumber</tt> class. Notice that the Java attribute is not specific enough to preserve the typing. The simple type translator adds the type information to the resulting document to preserve the typing.
+
The [[#Figure 16-11|Simple Type Translator]] figure illustrates a type translation XML mapping for the <tt>number</tt> attribute of the <tt>PhoneNumber</tt> class. Notice that the Java attribute is not specific enough to preserve the typing. The simple type translator adds the type information to the resulting document to preserve the typing.
  
 
<span id="Figure 16-11"></span>
 
<span id="Figure 16-11"></span>
Line 472: Line 434:
 
[[Image:tcxmlfig.gif|Simple Type Translator ]]<br /><br />
 
[[Image:tcxmlfig.gif|Simple Type Translator ]]<br /><br />
  
By default, EclipseLink uses built-in read and write conversion pairs (see [[#Default Read Conversions]] and [[#Default Write Conversions]]).
+
By default, EclipseLink uses built-in read and write conversion pairs (see [[#Default Read Conversions|Default Read Conversions]] and [[#Default Write Conversions|Default Write Conversions]]).
  
 
You can override this behavior by specifying and configuring your own simple type translator, for example, to write XML binary data as <tt>Base64</tt>.
 
You can override this behavior by specifying and configuring your own simple type translator, for example, to write XML binary data as <tt>Base64</tt>.
  
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#CEGEEEGJ|Configuring a Simple Type Translator]].
+
For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Simple Type Translator|Configuring a Simple Type Translator]].
 
+
  
  
 
=====Default Read Conversions=====
 
=====Default Read Conversions=====
 
+
The [[#Table 16-2|Simple Type Translator Read Conversions]] table lists the built-in conversion pairs for reading XML elements. When the schema <tt><type></tt> attribute is specified and the simple type translator is enabled, the value read is converted to the corresponding Java type.
[[#Table 16-2|Simple Type Translator Read Conversions]] lists the built-in conversion pairs for reading XML elements. When the schema <tt><type></tt> attribute is specified and the simple type translator is enabled, the value read is converted to the corresponding Java type.
+
  
  
Line 579: Line 539:
 
|}
 
|}
  
<br />
 
  
 
=====Default Write Conversions=====
 
=====Default Write Conversions=====
 
+
The [[#Table 16-3|Simple Type Translator Write Conversions]] tabel lists the built-in conversion pairs for writing XML. When a Java class attribute is of a type in the following table and the simple type translator is enabled, the corresponding schema type is specified on the element written.
[[#Table 16-3|Simple Type Translator Write Conversions]] lists the built-in conversion pairs for writing XML. When a Java class attribute is of a type in [[#Table 16-3] and the simple type translator is enabled, the corresponding schema type is specified on the element written.
+
  
  
Line 660: Line 618:
 
|}
 
|}
  
<br />
 
 
====Transformation Mappings====
 
  
 +
===Transformation Mappings===
 
In some special circumstances, existing mapping types and their default Java to data source type handling may be insufficient. In these special cases, you can consider using a transformation mapping to perform specialized translations between how a value is represented in Java and in the data source.
 
In some special circumstances, existing mapping types and their default Java to data source type handling may be insufficient. In these special cases, you can consider using a transformation mapping to perform specialized translations between how a value is represented in Java and in the data source.
  
 
A transformation mapping is made up of the following two components:
 
A transformation mapping is made up of the following two components:
 
+
* attribute transformer (see [[Configuring%20a%20Mapping%20(ELUG)#Configuring Attribute Transformer|Configuring Attribute Transformer]]): performs the object attribute transformation at read (unmarshall) time;
* attribute transformer (see [[Configuring%20a%20Mapping%20(ELUG)#CHDBEEBB|Configuring Attribute Transformer]]): performs the object attribute transformation at read (unmarshall) time;
+
* field transformer (see [[Configuring%20a%20Mapping%20(ELUG)#Configuring Field Transformer Associations|Configuring Field Transformer Associations]]): performs the object attribute-to-field transformation at write (marshal) time;
* field transformer (see [[Configuring%20a%20Mapping%20(ELUG)#CHDIFJFA|Configuring Field Transformer Associations]]): performs the object attribute-to-field transformation at write (marshal) time;
+
  
 
You can implement a transformer as either a separate class or as a method on your domain object.
 
You can implement a transformer as either a separate class or as a method on your domain object.
Line 676: Line 631:
  
 
For more information, see the following:
 
For more information, see the following:
 +
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Transformation Mapping|Transformation Mapping]]
 +
* [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Transformation Mapping|EIS Transformation Mapping]]
 +
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Transformation Mapping|XML Transformation Mapping]]
  
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#CHDDBJJJ|Transformation Mapping]]
 
* [[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIJHDJ|EIS Transformation Mapping]]
 
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#BABHCFAB|XML Transformation Mapping]]
 
  
 
===Mappings and XPath===
 
===Mappings and XPath===
 
 
EclipseLink uses XPath statements to efficiently map the attributes of a Java object in EIS mappings to XML records and in XML mappings to XML documents. When you create such a mapping, you can specify the following:
 
EclipseLink uses XPath statements to efficiently map the attributes of a Java object in EIS mappings to XML records and in XML mappings to XML documents. When you create such a mapping, you can specify the following:
 
+
* [[#XPath by Position|XPath by Position]]
* [[#XPath by Position]
+
* [[#XPath by Path and Name|XPath by Path and Name]]
* [[#XPath by Path and Name]
+
* [[#XPath by Name|XPath by Name]]
* [[#XPath by Name]
+
* [[#Self XPath|Self XPath]]
* [[#Self XPath]
+
 
+
  
  
 
====XPath by Position====
 
====XPath by Position====
 
+
In a relational database table, columns are uniquely identified by name. In an XML document, elements are uniquely identified by name and position. The [[#Figure 16-12|Mapping to an XML Document by Position]] figure illustrates mapping to an XML document in which the first instance of the <tt>street</tt> element stores apartment information and the second instance of the <tt>street</tt> element stores street information. The [[#Figure 16-12|Mapping to an XML Document by Position]] figure shows that EclipseLink XML mappings preserve the order in which mappings are persisted and allow you to map Java object attributes to XML elements by position using an XPath like <tt>street[2]/text()</tt>.
In a relational database table, columns are uniquely identified by name. In an XML document, elements are uniquely identified by name and position. [[#Figure 16-12] illustrates mapping to an XML document in which the first instance of the <tt>street</tt> element stores apartment information and the second instance of the <tt>street</tt> element stores street information. [[#Figure 16-12] shows that EclipseLink XML mappings preserve the order in which mappings are persisted and allow you to map Java object attributes to XML elements by position using an XPath like <tt>street[2]/text()</tt>.
+
  
 
Other XML technologies only recognize the name of XML elements (not their position) and force you to store the simple values from elements with the same name in a collection.
 
Other XML technologies only recognize the name of XML elements (not their position) and force you to store the simple values from elements with the same name in a collection.
  
  
 +
<span id="Figure 16-12"></span>
 +
''''' Mapping to an XML Document by Position'''''
  
'''''Figure 16-12 Mapping to an XML Document by Position'''''
+
[[Image:xpposit.gif|Mapping to an XML Document by Position]]<br /><br />
  
[[Image:xpposit.gif|Description of Figure 16-12 follows]]<br />[img_text/xpposit Description of "Figure 16-12 Mapping to an XML Document by Position"]<br /><br />
 
  
 
====XPath by Path and Name====
 
====XPath by Path and Name====
 
+
In an XML document, attributes and elements are uniquely identified by a combination of name and path. The [[#Figure 16-13|Mapping to an XML Document by Path and Name]] figure illustrates that EclipseLink XML mappings can uniquely identify an XML element by name and path using an XPath such as <tt>item/name/text()</tt>. EclipseLink does not require a formal object relationship between XML elements <tt>lines</tt> and <tt>item</tt>.
In an XML document, attributes and elements are uniquely identified by a combination of name and path. [[#Figure 16-13] illustrates that EclipseLink XML mappings can uniquely identify an XML element by name and path using an XPath such as <tt>item/name/text()</tt>. EclipseLink does not require a formal object relationship between XML elements <tt>lines</tt> and <tt>item</tt>.
+
  
 
Other XML technologies force you to provide an object relationship for every level of nesting, resulting in the inclusion of many XML elements and classes simply to organize the data to satisfy this restriction. This produces an unnecessarily large object model that does not properly reflect the domain space.
 
Other XML technologies force you to provide an object relationship for every level of nesting, resulting in the inclusion of many XML elements and classes simply to organize the data to satisfy this restriction. This produces an unnecessarily large object model that does not properly reflect the domain space.
  
  
 +
<span id="Figure 16-13"></span>
 +
''''' Mapping to an XML Document by Path and Name'''''
  
'''''Figure 16-13 Mapping to an XML Document by Path and Name'''''
+
[[Image:xpnampat.gif|Mapping to an XML Document by Path and Name]]<br /><br />
  
[[Image:xpnampat.gif|Description of Figure 16-13 follows]]<br />[img_text/xpnampat Description of "Figure 16-13 Mapping to an XML Document by Path and Name"]<br /><br />
 
  
 
====XPath by Name====
 
====XPath by Name====
 
 
For simple XML documents, EclipseLink XML mappings can correctly place data in an XML document given an XPath of only an attribute or element name.
 
For simple XML documents, EclipseLink XML mappings can correctly place data in an XML document given an XPath of only an attribute or element name.
  
[[#Figure 16-14] illustrates mapping to a simple XML document by name. You can map Java object attribute <tt>name</tt> to XML attribute <tt>name</tt> by specifying an XPath of only <tt>@NAME</tt>. Similarly, you can map Java object attribute <tt>age</tt> to XML text node <tt>AGE</tt> by specifying an XPath of only <tt>AGE</tt>.
+
The [[#Figure 16-14|Mapping to a Simple XML Document by Name]] figure illustrates mapping to a simple XML document by name. You can map Java object attribute <tt>name</tt> to XML attribute <tt>name</tt> by specifying an XPath of only <tt>@NAME</tt>. Similarly, you can map Java object attribute <tt>age</tt> to XML text node <tt>AGE</tt> by specifying an XPath of only <tt>AGE</tt>.
  
  
 +
<span id="Figure 16-14"></span>
 +
''''' Mapping to a Simple XML Document by Name'''''
  
'''''Figure 16-14 Mapping to a Simple XML Document by Name'''''
+
[[Image:xpname.gif|Mapping to a Simple XML Document by Name]]<br /><br />
 
+
[[Image:xpname.gif|Description of Figure 16-14 follows]]<br />[img_text/xpname Description of "Figure 16-14 Mapping to a Simple XML Document by Name"]<br /><br />
+
 
+
Specifying an XPath by name provides the worst performance of the XPath mapping options. We recommend that you use XPath by position (see [[#XPath by Position]) or XPath by path and name (see [[#XPath by Path and Name]) instead.
+
  
 +
Specifying an XPath by name provides the worst performance of the XPath mapping options. We recommend that you use XPath by position (see [[#XPath by Position|XPath by Position]]) or XPath by path and name (see [[#XPath by Path and Name|XPath by Path and Name]]) instead.
  
  
 
====Self XPath====
 
====Self XPath====
 
 
For composite relationships, EclipseLink XML mappings can place data in the parent's element rather than an element nested within it given the self XPath (<tt>"."</tt>).
 
For composite relationships, EclipseLink XML mappings can place data in the parent's element rather than an element nested within it given the self XPath (<tt>"."</tt>).
  
[[#Figure 16-15] illustrates mapping to an XML document using the self XPath.
+
This figure illustrates mapping to an XML document using the self XPath.
  
  
 +
<span id="Figure 16-15"></span>
 +
''''' Mapping to a XML Document Using Self XPath'''''
  
'''''Figure 16-15 Mapping to a XML Document Using Self XPath'''''
+
[[Image:xpnameaddress.gif|Mapping to a XML Document Using Self XPath]]<br /><br />
  
[[Image:xpnameaddress.gif|Description of Figure 16-15 follows]]<br />[img_text/xpnameaddress Description of "Figure 16-15 Mapping to a XML Document Using Self XPath"]<br /><br />
+
Note that in the preceding example represented by the [[#Figure 16-15|Mapping to a XML Document Using Self XPath]] figure, <tt>name</tt> attribute of the <tt>Employee</tt> class is mapped using the <tt>@name</tt> annotation.
 
+
Note that in the preceding example represented by [[#Figure 16-15], <tt>name</tt> attribute of the <tt>Employee</tt> class is mapped using the <tt>@name</tt> annotation.
+
 
+
Using the self XPath, you can make EclipseLink perform all read and write operations in the parent's element and not an element nested within it (see [[#Mappings and the jaxb:class Customization]).
+
  
 +
Using the self XPath, you can make EclipseLink perform all read and write operations in the parent's element and not an element nested within it (see [[#Mappings and the jaxb:class Customization|Mappings and the jaxb:class Customization]]).
  
  
 
===Mappings and xsd:list and xsd:union Types===
 
===Mappings and xsd:list and xsd:union Types===
 
+
EclipseLink supports mapping to <tt>xsd:list</tt> and <tt>xsd:union</tt> types in EIS mappings to XML records and XML mappings to XML documents, as this table shows.
EclipseLink supports mapping to <tt>xsd:list</tt> and <tt>xsd:union</tt> types in EIS mappings to XML records and XML mappings to XML documents, as [[#Table 16-4] shows.
+
 
+
  
  
'''''Table 16-4 EclipseLink Support for xsd:list and xsd:union Types'''''
+
<span id="Table 16-4"></span>
 +
''''' EclipseLink Support for xsd:list and xsd:union Types'''''
  
 
{| class="RuleFormal" dir="ltr" title="EclipseLink Support for xsd:list and xsd:union Types" summary="This table summarizes EclipseLink support for mapping to xsd:list and xsd:union types." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
{| class="RuleFormal" dir="ltr" title="EclipseLink Support for xsd:list and xsd:union Types" summary="This table summarizes EclipseLink support for mapping to xsd:list and xsd:union types." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
! id="r1c1-t9" align="left" valign="bottom" | '''XSD'''
 
! id="r1c1-t9" align="left" valign="bottom" | '''XSD'''
! id="r1c2-t9" align="left" valign="bottom" | '''[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIFAJE EIS Direct Mapping][Introduction%20to%20XML%20Mappings%20(ELUG)#BABDBAGC XML Direct Mapping]<br />'''
+
! id="r1c2-t9" align="left" valign="bottom" | '''[[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Direct Mapping|EIS Direct Mapping]]<br>[[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Direct Mapping|XML Direct Mapping]]<br />'''
! id="r1c3-t9" align="left" valign="bottom" | '''[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEJDAFA EIS Composite Direct Collection Mapping][Introduction%20to%20XML%20Mappings%20(ELUG)#BABDIJCE XML Composite Direct Collection Mapping]<br />'''
+
! id="r1c3-t9" align="left" valign="bottom" | '''[[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Direct Collection Mapping|EIS Composite Direct Collection Mapping]]<br>[[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Direct Collection Mapping|XML Composite Direct Collection Mapping]]<br />'''
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r2c1-t9" headers="r1c1-t9" align="left" |
 
| id="r2c1-t9" headers="r1c1-t9" align="left" |
[[#Mapping an xsd:union Type]<br />
+
[[#Mapping an xsd:union Type|Mapping an xsd:union Type]]<br />
 
| headers="r2c1-t9 r1c2-t9" align="left" |
 
| headers="r2c1-t9 r1c2-t9" align="left" |
 
[[Image:support.gif|Supported]]<br />
 
[[Image:support.gif|Supported]]<br />
Line 772: Line 719:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t9" headers="r1c1-t9" align="left" |
 
| id="r3c1-t9" headers="r1c1-t9" align="left" |
[[#Mapping an xsd:list Type]<br />
+
[[#Mapping an xsd:list Type|Mapping an xsd:list Type]]<br />
 
| headers="r3c1-t9 r1c2-t9" align="left" |
 
| headers="r3c1-t9 r1c2-t9" align="left" |
 
[[Image:support.gif|Supported]]<br />
 
[[Image:support.gif|Supported]]<br />
Line 779: Line 726:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r4c1-t9" headers="r1c1-t9" align="left" |
 
| id="r4c1-t9" headers="r1c1-t9" align="left" |
[[#Mapping a List of Unions]<br />
+
[[#Mapping a List of Unions|Mapping a List of Unions]]<br />
 
| headers="r4c1-t9 r1c2-t9" align="left" |
 
| headers="r4c1-t9 r1c2-t9" align="left" |
 
[[Image:unsupport.gif|Unsupported]]<br />
 
[[Image:unsupport.gif|Unsupported]]<br />
Line 786: Line 733:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r5c1-t9" headers="r1c1-t9" align="left" |
 
| id="r5c1-t9" headers="r1c1-t9" align="left" |
[[#Mapping a Union of Lists]<br />
+
[[#Mapping a Union of Lists|Mapping a Union of Lists]]<br />
 
| headers="r5c1-t9 r1c2-t9" align="left" |
 
| headers="r5c1-t9 r1c2-t9" align="left" |
 
[[Image:support.gif|Supported]]<br />
 
[[Image:support.gif|Supported]]<br />
Line 793: Line 740:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r6c1-t9" headers="r1c1-t9" align="left" |
 
| id="r6c1-t9" headers="r1c1-t9" align="left" |
[[#Mapping a Union of Unions]<br />
+
[[#Mapping a Union of Unions|Mapping a Union of Unions]]<br />
 
| headers="r6c1-t9 r1c2-t9" align="left" |
 
| headers="r6c1-t9 r1c2-t9" align="left" |
 
[[Image:support.gif|Supported]]<br />
 
[[Image:support.gif|Supported]]<br />
Line 800: Line 747:
 
|}
 
|}
  
<br />
 
  
 
====Mapping an xsd:union Type====
 
====Mapping an xsd:union Type====
 
+
Use an <tt>EISDirectMapping</tt> (with XML records), an <tt>XMLDirectMapping</tt> or their subclasses to map a Java attribute to an <tt>xsd:union</tt> type, such as the following:
Use an <tt>EISDirectMapping</tt> (with XML records) or an <tt>XMLDirectMapping</tt> to map a Java attribute to an <tt>xsd:union</tt> type, such as:
+
 
+
+
 
     <xsd:simpleType name="size-type">
 
     <xsd:simpleType name="size-type">
 
         <xsd:union memberTypes="xsd:decimal xsd:string"/>
 
         <xsd:union memberTypes="xsd:decimal xsd:string"/>
Line 822: Line 765:
 
If your XML document specifies the <tt>xsi:type</tt> attribute on an element, then EclipseLink converts according to the <tt>xsi:type</tt> instead of trying the <tt>memberTypes</tt>.
 
If your XML document specifies the <tt>xsi:type</tt> attribute on an element, then EclipseLink converts according to the <tt>xsi:type</tt> instead of trying the <tt>memberTypes</tt>.
  
For more information, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABBFGBE Mapping to a Union Field with an XML Direct Mapping]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIFAJE EIS Direct Mapping]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Union Field with an XML Direct Mapping|Mapping to a Union Field with an XML Direct Mapping]]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Direct Mapping|EIS Direct Mapping]]).
 
+
 
+
  
 
====Mapping an xsd:list Type====
 
====Mapping an xsd:list Type====
 
 
You can map a Java attribute to an <tt>xsd:list</tt> type, such as:
 
You can map a Java attribute to an <tt>xsd:list</tt> type, such as:
 
 
 
  <xsd:simpleType name="sizes">
 
  <xsd:simpleType name="sizes">
 
     <xsd:list itemType="xsd:int"/>
 
     <xsd:list itemType="xsd:int"/>
Line 836: Line 774:
 
  </xsd:simpleType>
 
  </xsd:simpleType>
  
If you represent the <tt>xsd:list</tt> in your object model as a Java <tt>List</tt> type, use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records) or an <tt>XMLCompositeDirectCollectionMapping</tt> and use mapping method <tt>useCollectionClass</tt> to specify the <tt>List</tt> type of the Java attribute.
+
If you represent the <tt>xsd:list</tt> in your object model as a Java <tt>List</tt> type, use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records), an <tt>XMLCompositeDirectCollectionMapping</tt> or their subclasses and use the mapping method <tt>useCollectionClass</tt> to specify the <tt>List</tt> type of the Java attribute.
  
If you represent the list in your object model as a <tt>String</tt> of white space delimited tokens (for example, <tt>"aaa bbb ccc"</tt>), use an <tt>EISDirectMapping</tt> (with XML records) or an <tt>XMLDirectMappng</tt> to map this Java attribute to an <tt>xsd:list</tt> (for example, <tt><item>aaa bbb ccc</item></tt>).
+
If you represent the list in your object model as a <tt>String</tt> of white space delimited tokens (for example, <tt>"aaa bbb ccc"</tt>), use an <tt>EISDirectMapping</tt> (with XML records), an <tt>XMLDirectMapping</tt> or their subclasses to map this Java attribute to an <tt>xsd:list</tt> (for example, <tt><item>aaa bbb ccc</item></tt>).
  
 
In either case, you can configure whether or not the mapping unmarshalls (writes) the list to a single node, like <tt><item>aaa bbb ccc</item></tt>, or to multiple nodes, such as the following:
 
In either case, you can configure whether or not the mapping unmarshalls (writes) the list to a single node, like <tt><item>aaa bbb ccc</item></tt>, or to multiple nodes, such as the following:
Line 848: Line 786:
 
   
 
   
  
For more information on mapping to an <tt>xsd:list</tt> type using an <tt>XMLCompositeDirectCollectionMapping</tt>, see the following:
+
For more information on mapping to an <tt>xsd:list</tt> type using an <tt>XMLCompositeDirectCollectionMapping</tt> or its subclasses, see the following:
 
+
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Single Text Node with an XML Composite Direct Collection Mapping|Mapping to a Single Text Node with an XML Composite Direct Collection Mapping]]
* [Introduction%20to%20XML%20Mappings%20(ELUG)#BABHCGBI Mapping to a Single Text Node with an XML Composite Direct Collection Mapping]
+
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Single Attribute with an XML Composite Direct Collection Mapping|Mapping to a Single Attribute with an XML Composite Direct Collection Mapping]]
* [Introduction%20to%20XML%20Mappings%20(ELUG)#BABFDFCC Mapping to a Single Attribute with an XML Composite Direct Collection Mapping]
+
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#Specifying the Content Type of a Collection with an XML Composite Direct Collection Mapping|Specifying the Content Type of a Collection with an XML Composite Direct Collection Mapping]]
* [Introduction%20to%20XML%20Mappings%20(ELUG)#BABFBIEH Specifying the Content Type of a Collection with an XML Composite Direct Collection Mapping]
+
  
 
The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records).
 
The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records).
  
For more information about mapping to an <tt>xsd:list</tt> type using an <tt>XMLDirectMapping</tt>, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABJCIGH Mapping to a List Field with an XML Direct Mapping]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIFAJE EIS Direct Mapping]).
+
For more information about mapping to an <tt>xsd:list</tt> type using an <tt>XMLDirectMapping</tt> or its subclasses, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a List Field with an XML Direct Mapping|Mapping to a List Field with an XML Direct Mapping]]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Direct Mapping|EIS Direct Mapping]]).
 
+
  
  
 
====Mapping a List of Unions====
 
====Mapping a List of Unions====
 
+
Use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records), an <tt>XMLCompositeDirectCollectionMapping</tt> or their subclasses to map a Java attribute to an <tt>xsd:list</tt> that contains <tt>xsd:union</tt> types, such as:
Use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records) or an <tt>XMLCompositeDirectCollectionMapping</tt> to map a Java attribute to an <tt>xsd:list</tt> that contains <tt>xsd:union</tt> types, such as:
+
 
+
+
 
  <xsd:element name="listOfUnions" type="listOfUnions"/>
 
  <xsd:element name="listOfUnions" type="listOfUnions"/>
 
     <xsd:simpleType name="listOfUnions">
 
     <xsd:simpleType name="listOfUnions">
Line 877: Line 810:
 
When EclipseLink marshalls (writes) an object to XML, it does not rely on a single <tt>xsd:list</tt> <tt>itemType</tt>. Instead, for each item in the list, EclipseLink tries each <tt>memberType</tt> until the first successful conversion.
 
When EclipseLink marshalls (writes) an object to XML, it does not rely on a single <tt>xsd:list</tt> <tt>itemType</tt>. Instead, for each item in the list, EclipseLink tries each <tt>memberType</tt> until the first successful conversion.
  
For more information, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABEDDED Mapping to a List of Unions with an XML Composite Direct Collection Mapping]. The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEJDAFA EIS Composite Direct Collection Mapping]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a List of Unions with an XML Composite Direct Collection Mapping|Mapping to a List of Unions with an XML Composite Direct Collection Mapping]]. The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Direct Collection Mapping|EIS Composite Direct Collection Mapping]]).
 
+
  
  
 
====Mapping a Union of Lists====
 
====Mapping a Union of Lists====
 
 
You can map a Java attribute to an <tt>xsd:union</tt> type whose <tt>memberTypes</tt> are <tt>xsd:list</tt> types where each <tt>xsd:list</tt> contains items of a single type, such as:
 
You can map a Java attribute to an <tt>xsd:union</tt> type whose <tt>memberTypes</tt> are <tt>xsd:list</tt> types where each <tt>xsd:list</tt> contains items of a single type, such as:
 
 
 
  <xsd:element name="listOfUnions" type="UnionOfLists"/>
 
  <xsd:element name="listOfUnions" type="UnionOfLists"/>
 
     <xsd:simpleType name="UnionOfLists">
 
     <xsd:simpleType name="UnionOfLists">
Line 903: Line 832:
 
If you represent the list in your object model as a <tt>String</tt> of white space delimited tokens (for example, <tt>"aaa bbb ccc"</tt>), use an <tt>EISDirectMapping</tt> (with XML records) or an <tt>XMLDirectMappng</tt> to map this Java attribute to an <tt>xsd:list</tt> (for example, <tt><item>aaa bbb ccc</item></tt>).
 
If you represent the list in your object model as a <tt>String</tt> of white space delimited tokens (for example, <tt>"aaa bbb ccc"</tt>), use an <tt>EISDirectMapping</tt> (with XML records) or an <tt>XMLDirectMappng</tt> to map this Java attribute to an <tt>xsd:list</tt> (for example, <tt><item>aaa bbb ccc</item></tt>).
  
If you represent the list in your object model as a Java <tt>List</tt> type, use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records) or an <tt>XMLCompositeDirectCollectionMapping</tt>.
+
If you represent the list in your object model as a Java <tt>List</tt> type, use an <tt>EISCompositeDirectCollectionMapping</tt> (with XML records), an <tt>XMLCompositeDirectCollectionMapping</tt> or their subclasses.
  
 
For more information, see the following:
 
For more information, see the following:
 
+
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Union of Lists with an XML Direct Mapping|Mapping to a Union of Lists with an XML Direct Mapping]]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Direct Mapping|EIS Direct Mapping]]).
* [Introduction%20to%20XML%20Mappings%20(ELUG)#BABEFCEB Mapping to a Union of Lists with an XML Direct Mapping]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIFAJE EIS Direct Mapping]).
+
* [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Union of Lists with an XML Composite Direct Collection Mapping|Mapping to a Union of Lists with an XML Composite Direct Collection Mapping]]. The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Direct Collection Mapping|EIS Composite Direct Collection Mapping]]).
* [Introduction%20to%20XML%20Mappings%20(ELUG)#BABFCAFJ Mapping to a Union of Lists with an XML Composite Direct Collection Mapping]. The same applies to an <tt>EISCompositeDirectCollectionMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEJDAFA EIS Composite Direct Collection Mapping]).
+
 
+
  
  
 
====Mapping a Union of Unions====
 
====Mapping a Union of Unions====
 
+
Use an <tt>EISDirectMapping</tt> (with XML records), an <tt>XMLDirectMapping</tt> or their subclasses to map a Java attribute to an <tt>xsd:union</tt> that contains <tt>xsd:union</tt> types, such as:
Use an <tt>EISDirectMapping</tt> (with XML records) or an <tt>XMLDirectMapping</tt> to map a Java attribute to an <tt>xsd:union</tt> that contains <tt>xsd:union</tt> types, such as:
+
 
+
 
   
 
   
 
  <xsd:simpleType name="UnionOfUnions">
 
  <xsd:simpleType name="UnionOfUnions">
Line 948: Line 873:
 
Note that in this example, valid XML documents may contain any of <tt>xsd:date</tt>, <tt>xsd:integer</tt>, <tt>xsd:string</tt>, or <tt>xsd:float</tt>.
 
Note that in this example, valid XML documents may contain any of <tt>xsd:date</tt>, <tt>xsd:integer</tt>, <tt>xsd:string</tt>, or <tt>xsd:float</tt>.
  
For more information, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABDEFJE Mapping to a Union of Unions with an XML Direct Mapping]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHEIFAJE EIS Direct Mapping]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#Mapping to a Union of Unions with an XML Direct Mapping|Mapping to a Union of Unions with an XML Direct Mapping]]. The same applies to an <tt>EISDirectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Direct Mapping|EIS Direct Mapping]]).
 
+
  
  
 
===Mappings and the jaxb:class Customization===
 
===Mappings and the jaxb:class Customization===
 
 
Using the <tt>jaxb:class</tt> customization, you can declaratively specify an application-specific subclass of a schema-derived implementation class. This lets you write your own classes that extend JAXB's generated implementation classes. The JAXB runtime binding framework can then access your subclasses.
 
Using the <tt>jaxb:class</tt> customization, you can declaratively specify an application-specific subclass of a schema-derived implementation class. This lets you write your own classes that extend JAXB's generated implementation classes. The JAXB runtime binding framework can then access your subclasses.
  
When you create an EIS composite object mapping to XML records or an XML composite object mapping to XML documents, you can configure the mapping's XPath ( [Configuring%20a%20Mapping%20(ELUG)#CEGDGEEJ Configuring XPath]) to accommodate <tt>jaxb:class</tt> customizations with the following XSD structures:
+
When you create an EIS composite object mapping to XML records or an XML composite object mapping to XML documents, you can configure the mapping's XPath ( [[Configuring%20a%20Mapping%20(ELUG)#Configuring XPath|Configuring XPath]]) to accommodate <tt>jaxb:class</tt> customizations with the following XSD structures:
 
+
* [[#all, choice, or sequence Structure|all, choice, or sequence Structure]]
* [[#all, choice, or sequence Structure]
+
* [[#group Structure|group Structure]]
* [[#group Structure]
+
* [[#sequence or choice Structure Containing a group|sequence or choice Structure Containing a group]]
* [[#sequence or choice Structure Containing a group]
+
* [[#group Structure Containing a sequence or choice|group Structure Containing a sequence or choice]]
* [[#group Structure Containing a sequence or choice]
+
* [[#group Structure Containing a group|group Structure Containing a group]]
* [[#group Structure Containing a group]
+
 
+
When mapping to <tt>jaxb:class</tt> customized structures, consider the limitations of EclipseLink support for this customization (see [[#Limitations of jaxb:class Customization Support]).
+
  
 +
When mapping to <tt>jaxb:class</tt> customized structures, consider the limitations of EclipseLink support for this customization (see [[#Limitations of jaxb:class Customization Support|Limitations of jaxb:class Customization Support]]).
  
  
 
====all, choice, or sequence Structure====
 
====all, choice, or sequence Structure====
 +
You can use the <tt>jaxb:class</tt> customization with an <tt>all</tt>, <tt>choice</tt>, or <tt>sequence</tt> structure. The [[#Example 16-1|jaxb:class Customization of an all Structure]] example shows a <tt>jaxb:class</tt> customization of an <tt>all</tt> structure.
  
You can use the <tt>jaxb:class</tt> customization with an <tt>all</tt>, <tt>choice</tt>, or <tt>sequence</tt> structure. [[#Example 16-1] shows a <tt>jaxb:class</tt> customization of an <tt>all</tt> structure.
 
  
 
+
<span id="Example 16-1"></span>
 
+
''''' jaxb:class Customization of an all Structure'''''
'''''Example 16-1 jaxb:class Customization of an all Structure'''''
+
 
+
+
 
  <xsd:element name="employee">
 
  <xsd:element name="employee">
 
     <xsd:complexType>
 
     <xsd:complexType>
Line 997: Line 915:
 
This directs the JAXB compiler to create an inner class named <tt>Period</tt> in the owning element's class for the <tt>all</tt> structure. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this inner class.
 
This directs the JAXB compiler to create an inner class named <tt>Period</tt> in the owning element's class for the <tt>all</tt> structure. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this inner class.
  
For more information, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABEHHIE XML Composite Object Mapping]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHECCJEI EIS Composite Object Mapping]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Object Mapping|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Object Mapping|EIS Composite Object Mapping]]).
 
+
  
  
 
====group Structure====
 
====group Structure====
 +
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure, as this example shows.
  
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure, as [[#Example 16-2] shows.
 
  
 
+
<span id="Example 16-2"></span>
 
+
''''' jaxb:class Customization of a group Structure'''''
'''''Example 16-2 jaxb:class Customization of a group Structure'''''
+
 
+
+
 
  <xsd:group name="G1">
 
  <xsd:group name="G1">
 
     <xsd:annotation>
 
     <xsd:annotation>
Line 1,033: Line 947:
 
This directs the JAXB compiler to create an external wrapper class named <tt>Period</tt> for the <tt>group</tt> structure. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this external wrapper class.
 
This directs the JAXB compiler to create an external wrapper class named <tt>Period</tt> for the <tt>group</tt> structure. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this external wrapper class.
  
For more information, see [Introduction%20to%20XML%20Mappings%20(ELUG)#BABEHHIE XML Composite Object Mapping]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [Introduction%20to%20EIS%20Mappings%20(ELUG)#CHECCJEI EIS Composite Object Mapping]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Object Mapping|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Object Mapping|EIS Composite Object Mapping]]).
 
+
  
  
 
====sequence or choice Structure Containing a group====
 
====sequence or choice Structure Containing a group====
 +
You can use the <tt>jaxb:class</tt> customization with a <tt>sequence</tt> or <tt>choice</tt> structure that contains a <tt>group</tt>. The [[#Example 16-3|jaxb:class Customization of a sequence Structure Containing a group]] example shows a <tt>jaxb:class</tt> customization of a <tt>sequence</tt> structure containing a <tt>group</tt> structure.
  
You can use the <tt>jaxb:class</tt> customization with a <tt>sequence</tt> or <tt>choice</tt> structure that contains a <tt>group</tt>. [[#Example 16-3] shows a <tt>jaxb:class</tt> customization of a <tt>sequence</tt> structure containing a <tt>group</tt> structure.
 
  
 
+
<span id="Example 16-3"></span>
 
+
''''' jaxb:class Customization of a sequence Structure Containing a group'''''
'''''Example 16-3 jaxb:class Customization of a sequence Structure Containing a group'''''
+
 
+
+
 
  <xsd:element name="employee">
 
  <xsd:element name="employee">
 
     <xsd:complexType>
 
     <xsd:complexType>
Line 1,075: Line 985:
 
   
 
   
 
  </xsd:group>
 
  </xsd:group>
 
  
  
 
This directs the JAXB compiler to create an inner class named <tt>EmploymentInfo</tt> in the owning element's class for the <tt>sequence</tt> structure and an external wrapper class named <tt>Period</tt> for the <tt>group</tt> structure. The inner class references the external wrapper class. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this inner class.
 
This directs the JAXB compiler to create an inner class named <tt>EmploymentInfo</tt> in the owning element's class for the <tt>sequence</tt> structure and an external wrapper class named <tt>Period</tt> for the <tt>group</tt> structure. The inner class references the external wrapper class. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this inner class.
  
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#BABEHHIE|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHECCJEI|EIS Composite Object Mapping]].
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Object Mapping|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Object Mapping|EIS Composite Object Mapping]]).
 +
 
  
 
====group Structure Containing a sequence or choice====
 
====group Structure Containing a sequence or choice====
 +
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure that contains a <tt>sequence</tt> or <tt>choice</tt>. The [[#Example 16-4|jaxb:class Customization of a group Structure Containing a sequence]] example shows a <tt>jaxb:class</tt> customization of a <tt>group</tt> structure containing a <tt>sequence</tt> structure.
  
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure that contains a <tt>sequence</tt> or <tt>choice</tt>. [[#Example 16-4] shows a <tt>jaxb:class</tt> customization of a <tt>group</tt> structure containing a <tt>sequence</tt> structure.
 
  
 
+
<span id="Example 16-4"></span>
 
+
''''' jaxb:class Customization of a group Structure Containing a sequence'''''
'''''Example 16-4 jaxb:class Customization of a group Structure Containing a sequence'''''
+
 
+
+
 
  <xsd:group name="G1">
 
  <xsd:group name="G1">
 
     <xsd:annotation>
 
     <xsd:annotation>
Line 1,120: Line 1,027:
 
   
 
   
 
  </xsd:element>
 
  </xsd:element>
 
  
  
 
This directs the JAXB compiler to create an external wrapper class named <tt>EmploymentInfo</tt> for the <tt>group</tt> structure and an inner class named <tt>Period</tt> in the external wrapper class for the <tt>sequence</tt> structure. The owning element references the external wrapper class. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this external wrapper class.
 
This directs the JAXB compiler to create an external wrapper class named <tt>EmploymentInfo</tt> for the <tt>group</tt> structure and an inner class named <tt>Period</tt> in the external wrapper class for the <tt>sequence</tt> structure. The owning element references the external wrapper class. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to this external wrapper class.
  
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#BABEHHIE|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHECCJEI|EIS Composite Object Mapping]]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Object Mapping|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Object Mapping|EIS Composite Object Mapping]]).
 +
 
  
 
====group Structure Containing a group====
 
====group Structure Containing a group====
 +
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure that contains another <tt>group</tt> structure, as the [[#Example 16-5|jaxb:class Customization of a group Structure Containing a group]] example shows.
  
You can use the <tt>jaxb:class</tt> customization with a <tt>group</tt> structure that contains another <tt>group</tt> structure, as [[#Example 16-5] shows.
 
  
 
+
<span id="Example 16-5"></span>
 
+
''''' jaxb:class Customization of a group Structure Containing a group'''''
'''''Example 16-5 jaxb:class Customization of a group Structure Containing a group'''''
+
 
+
+
 
  <xsd:group name="G1">
 
  <xsd:group name="G1">
 
     <xsd:annotation>
 
     <xsd:annotation>
Line 1,168: Line 1,072:
 
     </xsd:complexType>
 
     </xsd:complexType>
 
  </xsd:element>
 
  </xsd:element>
 
  
  
 
This directs the JAXB compiler to create a wrapper class named <tt>EmploymentInfo</tt> for the <tt>group</tt> structure that the owning element's class references and another wrapper class named <tt>Period</tt> for the <tt>group</tt> structure that the <tt>EmploymentInfo</tt> class references. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to these wrapper classes.
 
This directs the JAXB compiler to create a wrapper class named <tt>EmploymentInfo</tt> for the <tt>group</tt> structure that the owning element's class references and another wrapper class named <tt>Period</tt> for the <tt>group</tt> structure that the <tt>EmploymentInfo</tt> class references. Use an <tt>EISCompositeObjectMapping</tt> (with XML records) or an <tt>XMLCompositeObjectMapping</tt> to map a Java attribute to these wrapper classes.
  
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#BABEHHIE|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#CHECCJEI|EIS Composite Object Mapping]]).
+
For more information, see [[Introduction%20to%20XML%20Mappings%20(ELUG)#XML Composite Object Mapping|XML Composite Object Mapping]]. The same applies to an <tt>EISCompositeObjectMapping</tt> with XML records (see [[Introduction%20to%20EIS%20Mappings%20(ELUG)#EIS Composite Object Mapping|EIS Composite Object Mapping]]).
  
====Limitations of jaxb:class Customization Support====
 
  
 +
====Limitations of jaxb:class Customization Support====
 
When mapping to jaxb:class customized structures, consider the following limitations:
 
When mapping to jaxb:class customized structures, consider the following limitations:
 
 
* Unbounded structures are not supported.
 
* Unbounded structures are not supported.
 
* Partial validation is not supported.
 
* Partial validation is not supported.
* When mapping sequence elements to a composite object, the XML schema must order the elements so that the elements you map to the composite object are kept together.The <tt>sequence</tt> structure forces all elements to occur in the order in which they are specified in the XML schema. Consider the XML schema shown in [[#Example 16-6]. A valid XML instance must contain the sequence elements in the specified order:<tt>street</tt>, <tt>customerName</tt>, <tt>city</tt>In this example, you want to map the <tt>customerName</tt> attribute with a direct mapping and you want to map the <tt>street</tt> and <tt>city</tt> attributes to a composite <tt>Address</tt> object. Depending on the order in which you define the mappings, EclipseLink will marshall invalid XML document instances in the order<tt>customerName</tt>, <tt>street</tt>, <tt>city</tt>or<tt>street</tt>, <tt>city</tt>, <tt>customerName</tt>.'''''Example 16-6 XML Schema With Unsupported Sequence Element Order'''''  
+
* When mapping sequence elements to a composite object, the XML schema must order the elements so that the elements you map to the composite object are kept together.<br>The <tt>sequence</tt> structure forces all elements to occur in the order in which they are specified in the XML schema. Consider the XML schema shown in the [[#Example 16-6|XML Schema With Unsupported Sequence Element Order]] example. A valid XML instance must contain the sequence elements in the specified order:<br><tt>street</tt>, <tt>customerName</tt>, <tt>city</tt><br>In this example, you want to map the <tt>customerName</tt> attribute with a direct mapping and you want to map the <tt>street</tt> and <tt>city</tt> attributes to a composite <tt>Address</tt> object. Depending on the order in which you define the mappings, EclipseLink will marshall invalid XML document instances in the order<br><tt>customerName</tt>, <tt>street</tt>, <tt>city</tt><br>or<br><tt>street</tt>, <tt>city</tt>, <tt>customerName</tt>.
 +
 
 +
 
 +
<span id="Example 16-6"></span>
 +
''''' XML Schema With Unsupported Sequence Element Order'''''  
 
  <xs:element name="customer">
 
  <xs:element name="customer">
 
     <xs:complexType>
 
     <xs:complexType>
Line 1,192: Line 1,098:
 
     </xs:complexType>
 
     </xs:complexType>
 
  </xs:element>
 
  </xs:element>
To correct this problem, modify the XML schema to keep the elements you want to map to the composite object together (see [[#Example 16-7]) and define the mappings in the order specified by the XML schema.'''''Example 16-7 XML Schema With Supported Sequence Element Order'''''  
+
 
 +
 
 +
To correct this problem, modify the XML schema to keep the elements you want to map to the composite object together (see the [[#Example 16-7|XML Schema With Supported Sequence Element Order]] example) and define the mappings in the order specified by the XML schema.
 +
 
 +
<span id="Example 16-7"></span>
 +
''''' XML Schema With Supported Sequence Element Order'''''  
 
  <xs:element name="customer">
 
  <xs:element name="customer">
 
     <xs:complexType>
 
     <xs:complexType>
Line 1,203: Line 1,114:
 
     </xs:complexType>
 
     </xs:complexType>
 
  </xs:element>
 
  </xs:element>
 
 
  
  
 
===Mappings and JAXB Typesafe Enumerations===
 
===Mappings and JAXB Typesafe Enumerations===
 +
JAXB binds a typesafe enumeration class to a named simple type definition with a <tt>basetype</tt> that derives from <tt>xsd:NCName</tt> and has <tt>enumeration</tt> facets (see this example).
  
JAXB binds a typesafe enumeration class to a named simple type definition with a <tt>basetype</tt> that derives from <tt>xsd:NCName</tt> and has <tt>enumeration</tt> facets (see [[#Example 16-8]).
+
<span id="Example 16-8"></span>
 
+
''''' Schema Fragment with Typesafe Enumeration Declaration'''''
 
+
 
+
'''''Example 16-8 Schema Fragment with Typesafe Enumeration Declaration'''''
+
+
 
  <simpleType name="NISTSchema-NCName-enumeration-1-Type">
 
  <simpleType name="NISTSchema-NCName-enumeration-1-Type">
 
     <restriction base="NCName">
 
     <restriction base="NCName">
Line 1,223: Line 1,129:
  
  
 +
You can map a Java attribute to such an enumeration using the <tt>JAXBTypesafeEnumConverter</tt> with an <tt>EISDirectMapping</tt> or <tt>EISCompositeDirectCollectionMapping</tt> with XML records, or with an <tt>XMLDirectMapping</tt>, <tt>XMLCompositeDirectCollectionMapping</tt> or their subclasses with XML documents.
  
You can map a Java attribute to such an enumeration using the <tt>JAXBTypesafeEnumConverter</tt> with an <tt>EISDirectMapping</tt> or <tt>EISCompositeDirectCollectionMapping</tt> with XML records or with an <tt>XMLDirectMapping</tt> or <tt>XMLCompositeDirectCollectionMapping</tt> with XML documents.
+
The Workbench does not support the <tt>JAXBTypesafeEnumConverter</tt> directly: to configure a mapping with this converter, you must use a descriptor amendment method (see [[Configuring%20a%20Mapping%20(ELUG)#Configuring a JAXB Typesafe Enumeration Converter|Configuring a JAXB Typesafe Enumeration Converter]]).
  
The Workbench does not support the <tt>JAXBTypesafeEnumConverter</tt> directly: to configure a mapping with this converter, you must use a descriptor amendment method (see [[Configuring%20a%20Mapping%20(ELUG)#CEGFAHGD|Configuring a JAXB Typesafe Enumeration Converter]]).
+
If you create a project and object model using the EclipseLink JAXB compiler (see [[Creating%20an%20XML%20Project%20(ELUG)#Creating an XML Project from an XML Schema|Creating an XML Project from an XML Schema]]), the compiler will create the type safe enumeration class and a class with descriptor amendment methods and register the required amendment methods automatically (see [[Introduction%20to%20XML%20Projects%20(ELUG)#Typesafe Enumeration Converter Amendment Method DescriptorAfterLoads Class|Typesafe Enumeration Converter Amendment Method DescriptorAfterLoads Class]]).
  
If you create a project and object model using the EclipseLink JAXB compiler (see [[Creating%20an%20XML%20Project%20(ELUG)#BABCGEIC|Creating an XML Project from an XML Schema]]), the compiler will create the type safe enumeration class and a class with descriptor amendment methods and register the required amendment methods automatically (see [[Introduction%20to%20XML%20Projects%20(ELUG)#BABIDGCC|Typesafe Enumeration Converter Amendment Method DescriptorAfterLoads Class]]).
 
  
==Mapping API==
 
  
 +
==Mapping API==
 
All the mapping classes are derived from the <tt>DatabaseMapping</tt> class.
 
All the mapping classes are derived from the <tt>DatabaseMapping</tt> class.
  
  
 
+
<span id="Table 16-5"></span>
'''''Table 16-5 Platform and Mapping Package Compatibility'''''
+
''''' Platform and Mapping Package Compatibility'''''
  
 
{| class="HRuleFormal" dir="ltr" title="Platform and Mapping Package Compatibility" summary="This table shows what mapping packages can be used for each supported platform." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
 
{| class="HRuleFormal" dir="ltr" title="Platform and Mapping Package Compatibility" summary="This table shows what mapping packages can be used for each supported platform." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
Line 1,259: Line 1,165:
 
|}
 
|}
  
<br />
 
  
==Relational Mappings==
 
  
 +
==Relational Mappings==
 
A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data-model.
 
A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data-model.
  
 
Relational mappings can also transform object data members that reference other domain objects that are stored in other tables in the database and are related through foreign keys.
 
Relational mappings can also transform object data members that reference other domain objects that are stored in other tables in the database and are related through foreign keys.
  
Use relational mappings in relational projects. For more information, see [[Introduction%20to%20Relational%20Projects%20(ELUG)#BABJIHFG|Building Relational Projects]].
+
Use relational mappings in relational projects. For more information, see [[Introduction%20to%20Relational%20Projects%20(ELUG)#Building Relational Projects|Building Relational Projects]].
  
 
For more information about relational mappings, see [[Relational Mappings (ELUG)]]
 
For more information about relational mappings, see [[Relational Mappings (ELUG)]]
  
==Object-Relational Data Type Mappings==
 
  
 +
 +
==Object-Relational Data Type Mappings==
 
An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings allow you to map an object model into an object-relational data type data-model.
 
An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings allow you to map an object model into an object-relational data type data-model.
  
Use object-relational data type mappings in relational projects. For more information, see [[Introduction%20to%20Relational%20Projects%20(ELUG)#BABJIHFG|Building Relational Projects]].
+
Use object-relational data type mappings in relational projects. For more information, see [[Introduction%20to%20Relational%20Projects%20(ELUG)#Building Relational Projects|Building Relational Projects]].
  
 
For more information about object-relational data type mappings, see [[Object-Relational Data Type Mappings (ELUG)]].
 
For more information about object-relational data type mappings, see [[Object-Relational Data Type Mappings (ELUG)]].
  
==XML Mappings==
 
  
 +
 +
==XML Mappings==
 
An XML mapping transforms object data members to the XML elements of an XML file whose structure is defined by an XML schema document (XSD).
 
An XML mapping transforms object data members to the XML elements of an XML file whose structure is defined by an XML schema document (XSD).
  
Use XML mappings in XML projects. For more information, see [[Introduction%20to%20XML%20Projects%20(ELUG)#BABCHIHJ|XML Project Concepts]].
+
Use XML mappings in XML projects. For more information, see [[Introduction%20to%20XML%20Projects%20(ELUG)#XML Project Concepts|XML Project Concepts]].
  
 
For more information about XML mappings, see [[XML Mappings (ELUG)]].
 
For more information about XML mappings, see [[XML Mappings (ELUG)]].
  
==EIS Mappings==
 
  
 +
 +
==EIS Mappings==
 
An EIS mapping transforms object data members to the EIS record format defined by the object's descriptor.
 
An EIS mapping transforms object data members to the EIS record format defined by the object's descriptor.
  
Use EIS mappings in EIS projects. For more information, see [[Introduction%20to%20EIS%20Projects%20(ELUG)#BABEDJBH|EIS Project Concepts]].
+
Use EIS mappings in EIS projects. For more information, see [[Introduction%20to%20EIS%20Projects%20(ELUG)#EIS Project Concepts|EIS Project Concepts]].
  
 
For more information about EIS mappings, see [[EIS Mappings (ELUG)]].
 
For more information about EIS mappings, see [[EIS Mappings (ELUG)]].
 +
 +
  
  
Line 1,302: Line 1,212:
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
 
[[Category: Concept]]
 
[[Category: Concept]]
[[Category: Draft]]
+
[[Category: Release 1]]

Latest revision as of 11:23, 18 July 2012

Elug draft icon.png For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/


Contents

Related Topics
EclipseLink can transform data between an object representation and a representation specific to a data source. This transformation is called mapping and it is the core of an EclipseLink project.

A mapping corresponds to a single data member of a domain object. It associates the object data member with its data source representation and defines the means of performing the two-way conversion between object and data source.


Mapping Types

This table describes the mapping types that EclipseLink supports.


Type Description EclipseLink Workbench Java

Relational

Mappings that transform any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data model.

Supported

Supported

Object-relational data type

Mappings that transform certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings let you map an object model into an object-relational data type data model.

Unsupported

Supported

EIS

Mappings that transform object data members to the EIS record format defined by the object's descriptor.

Supported

Supported

XML

Mappings that transform object data members to the XML elements of an XML document whose structure is defined by an XML schema document (XSD).

Supported

Supported


For more information, see the following:


Mapping Concepts

This section describes concepts unique to EclipseLink mappings, including the following:


Mapping Architecture

To define a mapping, you draw upon the following components:

  • The data representation specific to the data source (such as a relational database table or schema-defined XML element) in which you store the object's data.
  • A descriptor for a particular object class.
  • An object class to map.


Note: A mapping is the same regardless of whether your project is persistent or nonpersistent.


For an example of a typical EclipseLink mapping, see Example Mapping.

The type of data source you define in your EclipseLink project determines the type of mappings you can use and how you configure them. In a persistent project, you use mappings to persist to a data source. In a nonpersistent project, you use mappings simply to transform between the object format and some other data representation (such as XML). For more information about data source and project types, see EclipseLink Project Types.

A descriptor represents a particular domain object: it describes the object's class. It owns mappings: one mapping for each of the class data members that you intend to persist or transform in memory.


Note: Persistence is applicable at the descriptor level.


For more information about descriptors, see Introduction to Descriptors.

EclipseLink provides mappings to handle a wide variety of data types and data representations. For more information, see Mapping Types.

All mappings are subclasses of the org.eclipse.persistence.mappings.DatabaseMapping class. For more information about the mapping API, see Mapping API.


Example Mapping

Although EclipseLink supports more complex mappings, most EclipseLink classes map to a single database table or XML element that defines the type of information available in the class. Each object instance of a given class maps to a single row comprising the object's attributes, plus an identifier (the primary key) that uniquely identifies the object.

The How Classes and Objects Map to a Database Table figure illustrates the simplest database mapping case in which:

  • Table_X in the database represents Class_X.
  • Object_X1 and Object_X2 are instances of Class_X.
  • Individual rows in Table_X represent Object_X1 and Object_X2, as well as any other instances of Class_X.


How Classes and Objects Map to a Database Table

How Classes and Objects Map to a Database Table

EclipseLink provides you with the tools to build these mappings, from the simple mappings illustrated in the How Classes and Objects Map to a Database Tabl figure, to complex mappings.

For an additional example of a relational mapping, see the Direct-to-Field Mapping figure.

For an example of a nonrelational mapping, see the XML Transformation Mappings figure.


Automatic Mappings

Typically, you use the Workbench to define mappings on a class-by-class and data member-by-data-member basis manually (see Creating Mappings Manually During Development).

Alternatively, you can take advantage of the following:


JPA Automapping

To configure automapping in a JPA project, you just need to annotate your persistence classes with @Entity and define their primary key with @Id (or define the list of entities and their primary key fields in your orm.xml) and the EclipseLink JPA persistence provider will automatically map all unmapped properties. You can also configure persistence.xml properties to automatically create or replace the corresponding database tables. For more information, see EclipseLink JPA Overview.


Automapping with Workbench at Development Time

You can use Workbench Automap feature to automatically define default mappings for every class and data member in your project (see Creating Mappings Automatically During Development).

Workbench automapping is available for all project types and assumes that both the object model and database schema are already defined.


JAXB Project Generation at Development Time

JAXB provides an API and a tool that allow automatic two-way mapping between XML documents and Java objects. The JAXB compiler generates all the Java classes and mappings based on the provided Document Type Definition (DTD) and a schema definition.

For more information on JAXB, see Architecture for XML Binding (JAXB): A Primer at http://java.sun.com/developer/technicalArticles/xml/jaxb/indexl

For more information on XML mappings, see Introduction to XML Mappings.


Indirection (Lazy Loading)

By default, when EclipseLink retrieves a persistent object, it retrieves all of the dependent objects to which it refers. When you configure indirection (also known as lazy reading, lazy loading, and just-in-time reading) for an attribute mapped with a relationship mapping, EclipseLink uses an indirection object as a place holder for the referenced object: EclipseLink defers reading the dependent object until you access that specific attribute. This can result in a significant performance improvement, especially if the application is interested only in the contents of the retrieved object, rather than the objects to which it is related.

We strongly recommend using indirection for all relationship mappings. Not only does this lets you optimize data source access, but it also allows EclipseLink to optimize the unit of work processing, cache access, and concurrency.


Note: The use of indirection is especially important for providing a proper maintenance of bidirectional relationships. In this case, you must use indirection. If you are operating with collections, you must use transparent indirection (see Transparent Indirect Container Indirection).


The EclipseLink Indirection figure shows an indirection example. Without indirection, reading the Order object also reads the dependent collection of LineItem objects. With indirection, reading the Order object does not read the dependent collection of LineItem objects: the lineItems attribute refers to an indirection object. You can access other attributes (such as customerId), but EclipseLink reads the dependent LineItem objects only if and when you access the lineItems attribute.


EclipseLink Indirection

EclipseLink Indirection

EclipseLink supports the following types of indirection:

When using indirection with an object that your application serializes, you must consider the effect of any untriggered indirection objects at deserialization time (see Indirection, Serialization, and Detachment).

For information on configuring indirection, see Configuring Indirection (Lazy Loading).


Value Holder Indirection

Persistent classes that use indirection must replace relationship attributes with value holder attributes. A value holder is an instance of a class that implements the ValueHolderInterface interface, such as ValueHolder. This object stores the information necessary to retrieve the object it is replacing from the database. If the application does not access the value holder, the replaced object is never read from the database.

To obtain the object that the value holder replaces, use the getValue and setValue methods of the ValueHolderInterface. A convenient way of using these methods is to hide the getValue and setValue methods of the ValueHolderInterface inside get and set methods, as shown in the following illustrations.

The Address Object Not Read figure shows the Employee object being read from the database. The Address object is not read and will not be created unless it is accessed.


Address Object Not Read

Address Object Not Read

The first time the address is accessed, as in the Initial Request figure, the ValueHolder reads and returns the Address object.


Initial Request

Initial Request


Subsequent requests for the address do not access the database, as shown in the Subsequent Requests figure.


Subsequent Requests

Subsequent Requests

If you are using method access ( Configuring Method or Direct Field Accessing at the Mapping Level), the get and set methods specified in the mapping must access the instance of ValueHolderInterface, rather than the object referenced by the value holder. The application should not use these getter and setter, but use the getter and setter that hide the usage of value holders. For more information, see Configuring ValueHolder Indirection With Method Accessing.

For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).


Transparent Indirect Container Indirection

Transparent indirect container (see Configuring Container Policy) indirection lets you declare any relationship attribute of a persistent class that holds a collection of related objects as any of the following:

  • java.util.Collection
  • java.util.Hastable
  • java.util.List
  • java.util.Map
  • java.util.Set
  • java.util.Vector

EclipseLink will use an indirection object that implements the appropriate interface and also performs just-in-time reading of the related objects. When using transparent indirection, you do not have to declare the attributes as ValueHolderInterface.

Newly created collection mappings use transparent indirection by default if their attribute is not a ValueHolderInterface.

For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).

You can configure EclipseLink to automatically weave transparent indirect container indirection for JPA entities and Plain Old Java Object (POJO) classes. For more information, see the following:


Proxy Indirection

Introduced in JDK 1.3, the Java class Proxy lets you use dynamic proxy objects as place-holders for a defined interface. Certain EclipseLink mappings (see the Mapping Support for Indirection table) can be configured to use proxy indirection, which gives you the benefits of EclipseLink indirection without the need to include EclipseLink classes in your domain model. Proxy indirection is to one-to-one relationship mappings as indirect containers are to collection mappings.

To use proxy indirection, your domain model must satisfy all of the following criteria:

Before using proxy indirection, be aware of the restrictions it places on how you use the unit of work (see Proxy Indirection Restrictions|).

To configure proxy indirection, you can use the Workbench (see How to Configure Indirection Using Workbench) or Java in an amendment method (see Configuring Proxy Indirection).


Proxy Indirection Restrictions

Proxy objects in Java are only able to intercept messages sent. If a primitive operation such as ==, instanceof, or getClass is used on a proxy, it will not be intercepted. This limitation can require the application to be somewhat aware of the usage of proxy objects.

You cannot register the target of a proxy indirection implementation with a unit of work. Instead, first register the source object with the unit of work. This lets you retrieve a target object clone with a call to a getter on the source object clone.

For example:

UnitOfWork uow = session.acquireUnitOfWork();
Employee emp = (Employee)session.readObject(Employee.class);
 
// Register the source object
Employee empClone = (Employee)uow.registerObject(emp); 
 
// All of source object's relationships are cloned when source object is cloned
Address addressClone = empClone.getAddress();
addressClone.setCity("Toronto"); 

For more information about clones and the unit of work, see Introduction to EclipseLink Transactions.


Weaved Indirection

For JPA entities or POJO classes that you configure for weaving, EclipseLink weaves value holder indirection for one-to-one mappings. If you want EclipseLink to weave change tracking and your application includes collection mappings (one-to-many or many-to-many), then you must configure all collection mappings to use transparent indirect container indirection only (you may not configure your collection mappings to use eager loading nor value holder indirection).

For more information, see Using Weaving.


Indirection and JPA

When you set mapping annotation attribute fetch to lazy, the EclipseLink JPA persistence provider uses indirection.

By default, one-to-many and many-to-many relationships are lazy and use transparent indirection, while one-to-one and many-to-one relationships are not lazy.

If you set one-to-one or many-to-one relationships to lazy, and you enable weaving, the EclipseLink JPA persistence provider will use weaving to enable value holder indirection for these relationships.

For more information, see the following:


Indirection, Serialization, and Detachment

When using indirection (lazy loading), it is likely that a graph of persistent objects will contain untriggered indirection objects. Because indirection objects are transient and do not survive serialization between one JVM and another, untriggered indirection objects will trigger an error if the relationship is accessed after deserialization.

The application must ensure that any indirect relationships that will be required after deserialization have been instantiated before serialization. This can be done through accessing the get method for any relationship using ValueHolder or weaved indirection, and by sending the size() method to any relationship using transparent indirection. If the application desired the relationships to be always instantiated on serialization, the serialization writeObject() method could be overwritten in the persistent class to first instantiate the desired relationships. Caution should be used for objects with many or deep relationships to avoid serializing large object graphs: ideally, only the relationships required by the client should be instantiated.

When serializing JPA entities, any lazy relationships that have not been instantiated prior to serialization will trigger errors if they are accessed. If weaving is used on the server, and the entities are serialized to a client, the same weaved classes must exist on the client, either through static weaving of the jar, or through launching the client JVM using EclipseLink.

For more information, see the following:

Method Accessors and Attribute Accessors

By default, EclipseLink uses direct access to access public attributes. Using EclipseLink, you can configure field access at the project level (see Configuring Method or Direct Field Access at the Project Level) and at the mapping level (Configuring Method or Direct Field Accessing at the Mapping Level).


Mapping Converters and Transformers

If existing EclipseLink mappings do not meet your needs, you can create custom mappings using mapping extensions. These extensions include the following:


Note: You can use the mapping converters and transformers regardless of whether your data source is relational or nonrelational.


Serialized Object Converter

The serialized object converter is an extension of direct and direct collection mappings that lets you map complex objects into binary fields through Java object serialization. Serialized objects are normally stored in RAW or Binary Large Object (BLOB) fields in the database, or HEX or BASE64 elements in an XML document.

The Serialized Object Converter figure shows an example of a direct-to-field mappings that uses a serialized object converter. The attribute jobDescription contains a formatted text document that is stored in the JOB_DESC field of the database.

Serialized Object Converter (relational)

Serialized Object Converter (relational)


The Serialized Object Converter (nonrelational) figure demonstrates an example of a nonrelational mapping that uses a serialized object converter. The attribute jobDescription contains a formatted text document that EclipseLink stores in the JOB DESCRIPTION element of an XML schema.

Serialized Object Converter (nonrelational)

Serialized Object Converter (nonrelational)

The serialized object converter relies on the Java serializer. Before you map a domain object with the serialized object converter, ensure that the domain object implements the java.io.Serializable interface (or inherits that implementation) and marks all nonserializable fields transient.

For more information, see Configuring a Serialized Object Converter.


Type Conversion Converter

The type conversion converter is an extension of direct and direct collection mappings that lets you explicitly map a data source type to a Java type. For example, a Number in the data source can be mapped to a String in Java, or a java.util.Date in Java can be mapped to a java.sql.Date in the data source.

The Type Conversion Mapping (relational) figure illustrates a type conversion mapping (relational). Because the java.util.Date class is stored by default as a Timestamp in the database, it must first be converted to an explicit database type such as java.sql.Date (required only for DB2–most other databases have a single date data type that can store any date or time).

Type Conversion Mapping (relational)

Type Conversion Mapping (relational)


The Type Conversion Mapping (nonrelational) figure illustrates a type conversion mapping (nonrelational). java.util.Date object is mapped to a String in a XML schema.

Type Conversion Mapping (nonrelational)

Type Conversion Mapping (nonrelational)


You can use a type conversion converter to specify the specific database type when that type must be handled specially for the database. This includes support for the special Oracle JDBC binding options required for NCHAR, NVARCHAR2, and NCLOB fields as well as the special Oracle Thin JDBC insert and update requirements for handling BLOB and CLOB fields greater than 5K.

EclipseLink uses the NCharacter, NClob and NString types in the org.eclipse.persistence.platform.database.oracle package as the converter data type to support the NCHAR, NCLOB and NVARCHAR2 types. EclipseLink uses the java.sql.Blob and Clob types as the converter data type to support BLOB and CLOB values greater than 5K.

You can configure a type conversion converter to map a data source time type (such as TIMESTAMP) to a java.lang.String provided that the String value conforms to the following formats:

  • YYYY/MM/DD HH:MM:SS
  • YY/MM/DD HH:MM:SS
  • YYYY-MM-DD HH:MM:SS
  • YY-MM-DD HH:MM:SS

For more complex String to TIMESTAMP type conversion, consider a transformation mapping (see Transformation Mappings).

For more information, see Configuring a Type Conversion Converter.


Object Type Converter

The object type converter is an extension of direct and direct collection mappings that lets you match a fixed number of XML values to Java objects. Use this converter when the values in the schema differ from those in Java.

The Object Type XML Converter figure illustrates an object type conversion between the Employee attribute gender and the XML element gender. If the value of the Java object attribute is Female, EclipseLink stores it in the XML element as F.

Object Type XML Converter

Object Type XML Converter


For more information, see Configuring an Object Type Converter.


Simple Type Translator

The simple type translator is an extension of direct and direct collection mappings that lets you automatically translate an XML element value to an appropriate Java type based on the element's <type> attribute as defined in your XML schema.

You can use a simple type translator only when the mapping's XPath goes to a text node. You cannot use a simple type translator if the mapping's XPath goes to an attribute.

Using a simple type translator, you can make the XML document preserve type information. This is useful when your object model specifies generic object attributes such as java.lang.Object and java.io.Serializable, since they do not trigger specific type conversions in EclipseLink as do specific object attributes such as java.lang.Integer or java.util.Calendar.

The Simple Type Translator figure illustrates a type translation XML mapping for the number attribute of the PhoneNumber class. Notice that the Java attribute is not specific enough to preserve the typing. The simple type translator adds the type information to the resulting document to preserve the typing.

Simple Type Translator

Simple Type Translator

By default, EclipseLink uses built-in read and write conversion pairs (see Default Read Conversions and Default Write Conversions).

You can override this behavior by specifying and configuring your own simple type translator, for example, to write XML binary data as Base64.

For more information, see Configuring a Simple Type Translator.


Default Read Conversions

The Simple Type Translator Read Conversions table lists the built-in conversion pairs for reading XML elements. When the schema <type> attribute is specified and the simple type translator is enabled, the value read is converted to the corresponding Java type.


Simple Type Translator Read Conversions

Schema Type Java Type

base64Binary

Byte[]

boolean

Boolean

byte

Byte

date

Calendar

dateTime

Calendar

double

Double

float

Float

hexBinary

Byte[]

int

int

integer

BigInteger

long

Long

short

Short

string

String

time

Calendar

unsignedByte

Short

unsignedInt

Long

unsignedShort

Integer


Default Write Conversions

The Simple Type Translator Write Conversions tabel lists the built-in conversion pairs for writing XML. When a Java class attribute is of a type in the following table and the simple type translator is enabled, the corresponding schema type is specified on the element written.


Simple Type Translator Write Conversions

Java Type Schema Type

Byte[]

hexBinary

BigInteger

integer

Boolean

boolean

Byte

byte

Calendar

dateTime

Gregorian_Calendar

dateTime

Double

double

Float

float

Integer

int

Long

long

int

int

short

short

String

string


Transformation Mappings

In some special circumstances, existing mapping types and their default Java to data source type handling may be insufficient. In these special cases, you can consider using a transformation mapping to perform specialized translations between how a value is represented in Java and in the data source.

A transformation mapping is made up of the following two components:

You can implement a transformer as either a separate class or as a method on your domain object.

Within your implementation of the attribute and field transformer, you can take whatever actions are necessary to transform your application data to suit your data source, and vise versa.

For more information, see the following:


Mappings and XPath

EclipseLink uses XPath statements to efficiently map the attributes of a Java object in EIS mappings to XML records and in XML mappings to XML documents. When you create such a mapping, you can specify the following:


XPath by Position

In a relational database table, columns are uniquely identified by name. In an XML document, elements are uniquely identified by name and position. The Mapping to an XML Document by Position figure illustrates mapping to an XML document in which the first instance of the street element stores apartment information and the second instance of the street element stores street information. The Mapping to an XML Document by Position figure shows that EclipseLink XML mappings preserve the order in which mappings are persisted and allow you to map Java object attributes to XML elements by position using an XPath like street[2]/text().

Other XML technologies only recognize the name of XML elements (not their position) and force you to store the simple values from elements with the same name in a collection.


Mapping to an XML Document by Position

Mapping to an XML Document by Position


XPath by Path and Name

In an XML document, attributes and elements are uniquely identified by a combination of name and path. The Mapping to an XML Document by Path and Name figure illustrates that EclipseLink XML mappings can uniquely identify an XML element by name and path using an XPath such as item/name/text(). EclipseLink does not require a formal object relationship between XML elements lines and item.

Other XML technologies force you to provide an object relationship for every level of nesting, resulting in the inclusion of many XML elements and classes simply to organize the data to satisfy this restriction. This produces an unnecessarily large object model that does not properly reflect the domain space.


Mapping to an XML Document by Path and Name

Mapping to an XML Document by Path and Name


XPath by Name

For simple XML documents, EclipseLink XML mappings can correctly place data in an XML document given an XPath of only an attribute or element name.

The Mapping to a Simple XML Document by Name figure illustrates mapping to a simple XML document by name. You can map Java object attribute name to XML attribute name by specifying an XPath of only @NAME. Similarly, you can map Java object attribute age to XML text node AGE by specifying an XPath of only AGE.


Mapping to a Simple XML Document by Name

Mapping to a Simple XML Document by Name

Specifying an XPath by name provides the worst performance of the XPath mapping options. We recommend that you use XPath by position (see XPath by Position) or XPath by path and name (see XPath by Path and Name) instead.


Self XPath

For composite relationships, EclipseLink XML mappings can place data in the parent's element rather than an element nested within it given the self XPath (".").

This figure illustrates mapping to an XML document using the self XPath.


Mapping to a XML Document Using Self XPath

Mapping to a XML Document Using Self XPath

Note that in the preceding example represented by the Mapping to a XML Document Using Self XPath figure, name attribute of the Employee class is mapped using the @name annotation.

Using the self XPath, you can make EclipseLink perform all read and write operations in the parent's element and not an element nested within it (see Mappings and the jaxb:class Customization).


Mappings and xsd:list and xsd:union Types

EclipseLink supports mapping to xsd:list and xsd:union types in EIS mappings to XML records and XML mappings to XML documents, as this table shows.


EclipseLink Support for xsd:list and xsd:union Types

XSD EIS Direct Mapping
XML Direct Mapping
EIS Composite Direct Collection Mapping
XML Composite Direct Collection Mapping

Mapping an xsd:union Type

Supported

Unsupported

Mapping an xsd:list Type

Supported

Supported

Mapping a List of Unions

Unsupported

Supported

Mapping a Union of Lists

Supported

Supported

Mapping a Union of Unions

Supported

Unsupported


Mapping an xsd:union Type

Use an EISDirectMapping (with XML records), an XMLDirectMapping or their subclasses to map a Java attribute to an xsd:union type, such as the following:

    <xsd:simpleType name="size-type">
        <xsd:union memberTypes="xsd:decimal xsd:string"/>

    </xsd:simpleType>

When EclipseLink marshalls (writes) an object to XML, it uses its default conversion pairs to convert from the Java type to the appropriate xsd type.

In the case where the memberTypes map to the same Java type, EclipseLink marshalls using the first memberType in the union which allows a successful conversion. For example, if you map a Java type of byte[] to an xsd:union with memberTypes of hexBinary and base64Binary, then EclipseLink marshalls using the first memberType: hexBinary.

You can customize the default conversion pairs to control the Java type to xsd type conversion using XMLField method addConversion and configuring your mapping with that XMLField using EISDirectMapping or XMLDirectMapping method setField. For example, if the memberTypes were xsd:date and xsd:time and the Java attribute was of type java.util.Date instead of the JAXB 1.0 standard java.util.Calendar, you can modify the conversion pair for xsd:date to be java.util.Date.

When EclipseLink unmarshalls (reads) XML into an object, it tries each memberType in the order specified in the XSD until the first successful conversion is made.

If your XML document specifies the xsi:type attribute on an element, then EclipseLink converts according to the xsi:type instead of trying the memberTypes.

For more information, see Mapping to a Union Field with an XML Direct Mapping. The same applies to an EISDirectMapping with XML records (see EIS Direct Mapping).

Mapping an xsd:list Type

You can map a Java attribute to an xsd:list type, such as:

<xsd:simpleType name="sizes">
    <xsd:list itemType="xsd:int"/>

</xsd:simpleType>

If you represent the xsd:list in your object model as a Java List type, use an EISCompositeDirectCollectionMapping (with XML records), an XMLCompositeDirectCollectionMapping or their subclasses and use the mapping method useCollectionClass to specify the List type of the Java attribute.

If you represent the list in your object model as a String of white space delimited tokens (for example, "aaa bbb ccc"), use an EISDirectMapping (with XML records), an XMLDirectMapping or their subclasses to map this Java attribute to an xsd:list (for example, <item>aaa bbb ccc</item>).

In either case, you can configure whether or not the mapping unmarshalls (writes) the list to a single node, like <item>aaa bbb ccc</item>, or to multiple nodes, such as the following:


<item>aaa</item>
<item>bbb</item>
<item>ccc</item>

For more information on mapping to an xsd:list type using an XMLCompositeDirectCollectionMapping or its subclasses, see the following:

The same applies to an EISCompositeDirectCollectionMapping (with XML records).

For more information about mapping to an xsd:list type using an XMLDirectMapping or its subclasses, see Mapping to a List Field with an XML Direct Mapping. The same applies to an EISDirectMapping with XML records (see EIS Direct Mapping).


Mapping a List of Unions

Use an EISCompositeDirectCollectionMapping (with XML records), an XMLCompositeDirectCollectionMapping or their subclasses to map a Java attribute to an xsd:list that contains xsd:union types, such as:

<xsd:element name="listOfUnions" type="listOfUnions"/>
    <xsd:simpleType name="listOfUnions">
        <xsd:list>
            <xsd:simpleType>
                <xsd:union memberTypes="xsd:date xsd:integer"/>
            </xsd:simpleType>

        </xsd:list>
    </xsd:simpleType>

When EclipseLink marshalls (writes) an object to XML, it does not rely on a single xsd:list itemType. Instead, for each item in the list, EclipseLink tries each memberType until the first successful conversion.

For more information, see Mapping to a List of Unions with an XML Composite Direct Collection Mapping. The same applies to an EISCompositeDirectCollectionMapping with XML records (see EIS Composite Direct Collection Mapping).


Mapping a Union of Lists

You can map a Java attribute to an xsd:union type whose memberTypes are xsd:list types where each xsd:list contains items of a single type, such as:

<xsd:element name="listOfUnions" type="UnionOfLists"/>
    <xsd:simpleType name="UnionOfLists">
        <xsd:union memberTypes="xsd:double">
            <xsd:simpleType>
                <xsd:list itemType="xsd:date"/>
            </xsd:simpleType>

            <xsd:simpleType>
                <xsd:list itemType="xsd:integer"/>
            </xsd:simpleType>
        </xsd:union>
    </xsd:simpleType>

Note that in this example, valid XML documents contain either all xsd:double, all xsd:date, or all xsd:integer values.

If you represent the list in your object model as a String of white space delimited tokens (for example, "aaa bbb ccc"), use an EISDirectMapping (with XML records) or an XMLDirectMappng to map this Java attribute to an xsd:list (for example, <item>aaa bbb ccc</item>).

If you represent the list in your object model as a Java List type, use an EISCompositeDirectCollectionMapping (with XML records), an XMLCompositeDirectCollectionMapping or their subclasses.

For more information, see the following:


Mapping a Union of Unions

Use an EISDirectMapping (with XML records), an XMLDirectMapping or their subclasses to map a Java attribute to an xsd:union that contains xsd:union types, such as:

<xsd:simpleType name="UnionOfUnions">

    <xsd:union>
        <xsd:simpleType>
            <xsd:union>
              <xsd:simpleType>
                <xsd:list itemType="xsd:date"/>
              </xsd:simpleType>

              <xsd:simpleType>
                <xsd:list itemType="xsd:integer"/>
              </xsd:simpleType>
              </xsd:union>
      </xsd:simpleType>
      <xsd:simpleType>

            <xsd:union>
              <xsd:simpleType>
                <xsd:list itemType="xsd:string"/>
              </xsd:simpleType>
              <xsd:simpleType>
                <xsd:list itemType="xsd:float"/>

              </xsd:simpleType>
              </xsd:union>
      </xsd:simpleType>
    </xsd:union>
</xsd:simpleType>

Note that in this example, valid XML documents may contain any of xsd:date, xsd:integer, xsd:string, or xsd:float.

For more information, see Mapping to a Union of Unions with an XML Direct Mapping. The same applies to an EISDirectMapping with XML records (see EIS Direct Mapping).


Mappings and the jaxb:class Customization

Using the jaxb:class customization, you can declaratively specify an application-specific subclass of a schema-derived implementation class. This lets you write your own classes that extend JAXB's generated implementation classes. The JAXB runtime binding framework can then access your subclasses.

When you create an EIS composite object mapping to XML records or an XML composite object mapping to XML documents, you can configure the mapping's XPath ( Configuring XPath) to accommodate jaxb:class customizations with the following XSD structures:

When mapping to jaxb:class customized structures, consider the limitations of EclipseLink support for this customization (see Limitations of jaxb:class Customization Support).


all, choice, or sequence Structure

You can use the jaxb:class customization with an all, choice, or sequence structure. The jaxb:class Customization of an all Structure example shows a jaxb:class customization of an all structure.


jaxb:class Customization of an all Structure

<xsd:element name="employee">
    <xsd:complexType>
        <xsd:all>
            <xsd:annotation>
                <xsd:appinfo>

                    <jaxb:class name="period"/>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:element name="startDate" type="xsd:date"/>
            <xsd:element name="endDate" type="xsd:date"/>
        </xsd:all>

    </xsd:complexType>
</xsd:element>


This directs the JAXB compiler to create an inner class named Period in the owning element's class for the all structure. Use an EISCompositeObjectMapping (with XML records) or an XMLCompositeObjectMapping to map a Java attribute to this inner class.

For more information, see XML Composite Object Mapping. The same applies to an EISCompositeObjectMapping with XML records (see EIS Composite Object Mapping).


group Structure

You can use the jaxb:class customization with a group structure, as this example shows.


jaxb:class Customization of a group Structure

<xsd:group name="G1">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:class name="period"/>
        </xsd:appinfo>

    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="startDate" type="xsd:date"/>
        <xsd:element name="endDate" type="xsd:date"/>
    </xsd:sequence>
</xsd:group>

<xsd:element name="employee">
    <xsd:complexType>
        <xsd:group ref="G1"/>
    </xsd:complexType>
</xsd:element>


This directs the JAXB compiler to create an external wrapper class named Period for the group structure. Use an EISCompositeObjectMapping (with XML records) or an XMLCompositeObjectMapping to map a Java attribute to this external wrapper class.

For more information, see XML Composite Object Mapping. The same applies to an EISCompositeObjectMapping with XML records (see EIS Composite Object Mapping).


sequence or choice Structure Containing a group

You can use the jaxb:class customization with a sequence or choice structure that contains a group. The jaxb:class Customization of a sequence Structure Containing a group example shows a jaxb:class customization of a sequence structure containing a group structure.


jaxb:class Customization of a sequence Structure Containing a group

<xsd:element name="employee">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:annotation>
                <xsd:appinfo>

                    <jaxb:class name="EmploymentInfo"/>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:element name="id" type="xsd:int"/>
            <xsd:group ref="G1"/>
        </xsd:sequence>

    </xsd:complexType>
</xsd:element>

<xsd:group name="G1">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:class name="Period"/>

        </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="startDate" type="xsd:date"/>
        <xsd:element name="endDate" type="xsd:date"/>
    </xsd:sequence>

</xsd:group>


This directs the JAXB compiler to create an inner class named EmploymentInfo in the owning element's class for the sequence structure and an external wrapper class named Period for the group structure. The inner class references the external wrapper class. Use an EISCompositeObjectMapping (with XML records) or an XMLCompositeObjectMapping to map a Java attribute to this inner class.

For more information, see XML Composite Object Mapping. The same applies to an EISCompositeObjectMapping with XML records (see EIS Composite Object Mapping).


group Structure Containing a sequence or choice

You can use the jaxb:class customization with a group structure that contains a sequence or choice. The jaxb:class Customization of a group Structure Containing a sequence example shows a jaxb:class customization of a group structure containing a sequence structure.


jaxb:class Customization of a group Structure Containing a sequence

<xsd:group name="G1">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:class name="EmploymentInfo"/>
        </xsd:appinfo>

    </xsd:annotation>
    <xsd:sequence>
        <xsd:annotation>
            <xsd:appinfo>
                <jaxb:class name="Period"/>
            </xsd:appinfo>

        </xsd:annotation>
        <xsd:element name="startDate" type="xsd:date"/>
        <xsd:element name="endDate" type="xsd:date"/>
    </xsd:sequence>
</xsd:group>

<xsd:element name="employee">

    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="id" type="xsd:int"/>
            <xsd:group ref="G1"/>
        </xsd:sequence>      
    </xsd:complexType>

</xsd:element>


This directs the JAXB compiler to create an external wrapper class named EmploymentInfo for the group structure and an inner class named Period in the external wrapper class for the sequence structure. The owning element references the external wrapper class. Use an EISCompositeObjectMapping (with XML records) or an XMLCompositeObjectMapping to map a Java attribute to this external wrapper class.

For more information, see XML Composite Object Mapping. The same applies to an EISCompositeObjectMapping with XML records (see EIS Composite Object Mapping).


group Structure Containing a group

You can use the jaxb:class customization with a group structure that contains another group structure, as the jaxb:class Customization of a group Structure Containing a group example shows.


jaxb:class Customization of a group Structure Containing a group

<xsd:group name="G1">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:class name="EmploymentInfo"/>
        </xsd:appinfo>

    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="id" type="xsd:int"/>
        <xsd:group ref="G2"/>
    </xsd:sequence>
</xsd:group>

<xsd:group name="G2">
    <xsd:annotation>
        <xsd:appinfo>
            <jaxb:class name="Period"/>
        </xsd:appinfo>
    </xsd:annotation>

    <xsd:sequence>
        <xsd:element name="startDate" type="xsd:date"/>
        <xsd:element name="endDate" type="xsd:date"/>
    </xsd:sequence>
</xsd:group>

<xsd:element name="employee">

    <xsd:complexType>
        <xsd:group ref="G1"/>
    </xsd:complexType>
</xsd:element>


This directs the JAXB compiler to create a wrapper class named EmploymentInfo for the group structure that the owning element's class references and another wrapper class named Period for the group structure that the EmploymentInfo class references. Use an EISCompositeObjectMapping (with XML records) or an XMLCompositeObjectMapping to map a Java attribute to these wrapper classes.

For more information, see XML Composite Object Mapping. The same applies to an EISCompositeObjectMapping with XML records (see EIS Composite Object Mapping).


Limitations of jaxb:class Customization Support

When mapping to jaxb:class customized structures, consider the following limitations:

  • Unbounded structures are not supported.
  • Partial validation is not supported.
  • When mapping sequence elements to a composite object, the XML schema must order the elements so that the elements you map to the composite object are kept together.
    The sequence structure forces all elements to occur in the order in which they are specified in the XML schema. Consider the XML schema shown in the XML Schema With Unsupported Sequence Element Order example. A valid XML instance must contain the sequence elements in the specified order:
    street, customerName, city
    In this example, you want to map the customerName attribute with a direct mapping and you want to map the street and city attributes to a composite Address object. Depending on the order in which you define the mappings, EclipseLink will marshall invalid XML document instances in the order
    customerName, street, city
    or
    street, city, customerName.


XML Schema With Unsupported Sequence Element Order

<xs:element name="customer">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="street" type="xs:string"/>
            <xs:element name="customerName" type="xs:string" />
            <xs:element name="city" type="xs:string"/>

        </xs:sequence>
    </xs:complexType>
</xs:element>


To correct this problem, modify the XML schema to keep the elements you want to map to the composite object together (see the XML Schema With Supported Sequence Element Order example) and define the mappings in the order specified by the XML schema.

XML Schema With Supported Sequence Element Order

<xs:element name="customer">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="customerName" type="xs:string"/>
            <xs:element name="street" type="xs:string"/>
            <xs:element name="city" type="xs:string"/>

        </xs:sequence>
    </xs:complexType>
</xs:element>


Mappings and JAXB Typesafe Enumerations

JAXB binds a typesafe enumeration class to a named simple type definition with a basetype that derives from xsd:NCName and has enumeration facets (see this example).

Schema Fragment with Typesafe Enumeration Declaration

<simpleType name="NISTSchema-NCName-enumeration-1-Type">
    <restriction base="NCName">
        <enumeration value="qbandwidth-and.software-use.too"/>
        <enumeration value="_effort-disseminate_and-devices.com"/>
    </restriction>
</simpleType>


You can map a Java attribute to such an enumeration using the JAXBTypesafeEnumConverter with an EISDirectMapping or EISCompositeDirectCollectionMapping with XML records, or with an XMLDirectMapping, XMLCompositeDirectCollectionMapping or their subclasses with XML documents.

The Workbench does not support the JAXBTypesafeEnumConverter directly: to configure a mapping with this converter, you must use a descriptor amendment method (see Configuring a JAXB Typesafe Enumeration Converter).

If you create a project and object model using the EclipseLink JAXB compiler (see Creating an XML Project from an XML Schema), the compiler will create the type safe enumeration class and a class with descriptor amendment methods and register the required amendment methods automatically (see Typesafe Enumeration Converter Amendment Method DescriptorAfterLoads Class).


Mapping API

All the mapping classes are derived from the DatabaseMapping class.


Platform and Mapping Package Compatibility

Platform Mapping Package

DatabasePlatform
For relational projects

org.eclipse.persistence.mappings
org.eclipse.persistence.mappings.xdb
org.eclipse.persistence.mappings.structures

EISPlatform
For EIS projects

org.eclipse.persistence.eis.mappings

XMLPlatform
For XML projects

org.eclipse.persistence.ox.mappings


Relational Mappings

A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings allow you to map an object model into a relational data-model.

Relational mappings can also transform object data members that reference other domain objects that are stored in other tables in the database and are related through foreign keys.

Use relational mappings in relational projects. For more information, see Building Relational Projects.

For more information about relational mappings, see Relational Mappings (ELUG)


Object-Relational Data Type Mappings

An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases such as Oracle Database. Object-relational data type mappings allow you to map an object model into an object-relational data type data-model.

Use object-relational data type mappings in relational projects. For more information, see Building Relational Projects.

For more information about object-relational data type mappings, see Object-Relational Data Type Mappings (ELUG).


XML Mappings

An XML mapping transforms object data members to the XML elements of an XML file whose structure is defined by an XML schema document (XSD).

Use XML mappings in XML projects. For more information, see XML Project Concepts.

For more information about XML mappings, see XML Mappings (ELUG).


EIS Mappings

An EIS mapping transforms object data members to the EIS record format defined by the object's descriptor.

Use EIS mappings in EIS projects. For more information, see EIS Project Concepts.

For more information about EIS mappings, see EIS Mappings (ELUG).




Copyright Statement

Back to the top