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.
Annotation Elements
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. |
Usage
Use this annotation to customize or extend the mapping metadata through the EclipseLink native API. With @Customizer
, you can access additional EclipseLink functionality and configurations.
You can specify @Customizer
on an Entity, MappedSuperclass, or Embeddable class.
Note: A |
Examples
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>
See Also
For more information, see:
"Binding JPA Entities to XML" in Solutions Guide for EclispeLink
EclipseLink Examples
http://wiki.eclipse.org/EclipseLink/Examples/JPA/MappingSelectionCriteria
"Customizers"
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Customizers