Use @Customizer
to specify a class that implements org.eclipse.persistence.config.DescriptorCustomizer
and is to run against an entity's class descriptor after all metadata processing has been completed.
Table 2-18 describes this annotation's elements.
Table 2-18 @Customizer Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Required) The name of the descriptor customizer to apply to the entity's descriptor. |
Use this annotation to customize or extend the mapping metadata through the TopLink native API. With @Customizer
, you can access additional TopLink functionality and configurations.
You can specify @Customizer
on an Entity, MappedSuperclass, or Embeddable class.
Note:
A @Customizer
is not inherited from its parent classes.
Example 2-36 show how to use the @Customizer
annotation with the following DescriptorCustomer
:
public class MyCustomizer implements DescriptorCustomizer {
public void customize(ClassDescriptor descriptor) {
DirectToFieldMapping genderMapping = (DirectToFieldMapping)descriptor.getMappingForAttributeName("gender");
ObjectTypeConverter converter = new ObjectTypeConverter();
convert.addConversionValue("M", Gender.MALE);
convert.addConversionValue("F", Gender.FEMALE);
genderMapping.setConverter(converter);
}
}
Example 2-36 Using @Customizer Annotation
@Entity
@Table(name="EMPLOYEE")
@Customizer(mypackage.MyCustomizer.class)
public class Employee implements Serializable {
...
}
Example 2-37 show how to use the <customizer>
element in the eclipselink-orm.xml
file.
Example 2-37 Using <customizer> XML
<entity class="Employee">
<table name="EMPLOYEE"/>
<customizer class="mypackage.MyCustomizer"/>
...
</entity>
For more information, see:
"Binding JPA Entities to XML" in Solutions Guide for Oracle TopLink