Use @Convert
to specify that a named converter should be used with the corresponding mapped attribute.
Table 2-14 describes this annotation's elements.
Table 2-14 @Convert Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Optional) The |
|
The @Convert
has the following reserved names:
serialized – Places the org.eclipse.persistence.mappings.converters.SerializedObjectConverter
on the associated mapping.
class-instance – Uses an ClassInstanceConverter
on the associated mapping. When using a ClassInstanceConverter
, the database representation is a String
representing the Class name and the object-model representation is an instance of that class built with a no-args constructor
none – Does not place a converter on the associated mapping.
Example 2-31 shows how to use the @Convert
annotation to define the gender
field.
Example 2-31 Using the @Convert
Annotation
@Entity
@Table(name="EMPLOYEE")
@Converter(
name="genderConverter",
converterClass=org.myorg.converters.GenderConverter.class
)
public class Employee implements Serializable{
...
@Basic
@Convert("genderConverter")
public String getGender() {
return gender;
}
...
}
For more information, see:
Understanding Oracle TopLink