There are multiple ways to customize your TopLink application, ranging from creating custom data types to using EclipseLink JPA extensions.
This chapter includes the following sections:
By design, TopLink can adapt to a variety of relational and nonrelational data sources.
To integrate TopLink with a data source that is not directly supported by the TopLink API, Oracle recommends that you use an EIS project (see Chapter 71, "Introduction to EIS Projects") or a XML project (see Chapter 47, "Introduction to XML Projects").
Using an EIS project, you can integrate your TopLink-enabled application with any nonrelational data source that supports a JCA adapter and any supported EIS record type, including indexed, mapped, or XML. If no JCA adapter exists for your target data source, you can concentrate your integration efforts on creating an adapter. Simultaneously, you can build your application according to JCA specifications. Although this still requires custom development effort, it is more efficient than trying to extend TopLink classes and provides you with a JCA adapter that you can leverage in any other project (making it a better value).
Using an XML project, you can integrate your TopLink-enabled application with Web services or other XML-message based designs.
The remainder of this chapter describes other customization options provided by the TopLink API.
TopLink provides support for all the most common Java data types. Table 13-1 lists the TopLink mapping extensions that you can use to support custom data types. You can also create your object converter to allow conversion between a data type and your own Java type.
Table 13-1 Mapping Extensions for Custom Data Types
Extension | Description |
---|---|
Object type converter (see Section 17.2.6.3, "Object Type Converter") |
An extension of direct and direct collection mappings that lets you match a fixed number of data values to Java objects. Use this converter when the values in the schema differ from those in Java |
Serialized object converter (see Section 17.2.6.1, "Serialized Object Converter") |
An extension of direct and direct collection mappings that lets you map serializable objects, such as multimedia data, to a binary format in a data source, such as a base64 element in an XML document or Binary Large Object (BLOB) field in a database |
Type conversion converter (see Section 17.2.6.2, "Type Conversion Converter") |
An extension of direct and direct collection mappings that lets you explicitly map a data source type to a Java type. For example, a |
Simple type translator (see Section 17.2.6.4, "Simple Type Translator") |
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 |
The source code to most public classes is available in <
TOPLINK_HOME
>\jlib\toplink-src.zip
.
This is provided for debugging purposes.
You can customize a session at run time by specifying a session customizer–a Java class that implements the oracle.toplink.tools.sessionconfiguration.SessionCustomizer
interface.
For more information, see the following:
Persistence unit property eclipselink.session.customizer
in "EclipseLink JPA Properties for Customization and Validation" table of EclipseLink Developer's Guide at http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_the_Persistence_Unit_Properties_for_Customization_and_Validation
You can customize a descriptor at run time by specifying a descriptor customizer–a Java class that implements the oracle.toplink.tools.sessionconfiguration.DescriptorCustomizer
interface.
For more information, see the following:
"How to Use the @Customizer Annotation" section of EclipseLink Developer's Guide at http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_the_.40Customizer_Annotation
Persistence unit property eclipselink.descriptor.customizer.<ENTITY>
in "EclipseLink JPA Properties for Customization and Validation" table of EclipseLink Developer's Guide at http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_the_Persistence_Unit_Properties_for_Customization_and_Validation
To customize descriptors, you can use their amendment methods.
For more information, see the following:
If you are developing a EclipseLink JPA application, use EclipseLink JPA metadata annotations and XML extensions for customization.
For more information, see "Using EclipseLink JPA Extensions" chapter of EclipseLink Developer's Guide at http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29
.