Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.5
  Go To Table Of Contents
 Search
 PDFComments
Comments


@StructConverter

Use @StructConverter to enable custom processing of java.sql.Struct types to process complex database types, such as spatial datatypes.

EclipseLink includes the JGeometryConverter class to convert the Oracle JGeometry spatial datatype.


NoteNote:

Unlike other converters, @StructConverter has its own interface.



Annotation Elements

Table 2-65 describes this annotation's elements.

Table 2-65 @StructConverter Annotation Elements

Annotation Element Description Default

name

The String name for your converter. Ensure that this name is unique across the persistence unit.

none

converter

The converter class as a String. This class must implement the org.eclipse.persistence.platform.database.converters.StructConverter interface.

none



Usage

You can use the existing @Convert annotation with its value attribute set to the StructConverter name – in this case, the appropriate settings are applied to the mapping. This setting is required on all mappings that use a type for which a StructConverter has been defined. Failing to configure the mapping with the @Convert will cause an error.

EclipseLink also includes additional converters, such as @ObjectTypeConverter and @TypeConverter.


Examples

Example 2-105 shows how to define the @StructConverter annotation.

Example 2-105 Using @StructConverter Annotation

@StructConverter(
     name="JGeometryConverter"
     converter=JGeometryConverter.class.getName())

You can specify the @StructConverter annotation anywhere in an Entity with the scope being the whole session. An exception is thrown if you add more than one StructConverter annotation that affects the same Java type. An @StructConverter annotation exists in the same namespaces as @Converter. A validation exception is thrown if you add an @Converter and an @StructConverter of the same name.


See Also

For more information, see: